From: Junio C Hamano Date: Tue, 20 Aug 2019 17:42:25 GMT Subject: Re: [PATCH v3 5/6] rebase -i: support --ignore-date Message-ID: In-Reply-To: <20190820034536.13071-6-rohit.ashiwal265@gmail.com> Rohit Ashiwal writes: > +/* Construct a free()able author string with current time as the author date */ > +static char *ignore_author_date(const char *author) > +{ > + int len = strlen(author); Mental note: ignore_author_date() would not allow author==NULL as its input. > @@ -1020,10 +1047,20 @@ static int run_git_commit(struct repository *r, > > if (res <= 0) > res = error_errno(_("could not read '%s'"), defmsg); > - else > + else { > + if (opts->ignore_date) { > + char *new_author = ignore_author_date(author); > + if (!author) > + BUG("ignore-date can only be used with " > + "rebase, which must set the author " > + "before committing the tree"); Yet, author is used and then checked for NULL-ness, which is backwards. Before we have a chance to issue this BUG(), we would already have segfaulted inside ignore_author_date().