From: Phillip Wood Date: Tue, 20 Aug 2019 18:30:54 GMT Subject: Re: [PATCH v3 5/6] rebase -i: support --ignore-date Message-ID: <3bdbcc74-0252-3d07-02b9-84789386fec6@gmail.com> In-Reply-To: On 20/08/2019 18:42, Junio C Hamano wrote: > 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(). > Good catch!