git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] bisect: address Coverity warning about potential double free

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 26, 2024, 02:29 UTC
Message-ID
<xmqqplmi3eyo.fsf@gitster.g>
In-Reply-To
<20241125163543.GA13033@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 34 quoted lines
>> Drop the `else` branch entirely as it seems to be a no-op anyway.
>> Another option might be to instead call `free_commit_list()` on `list`,
>> which is the modified version of `commit_list` and thus wouldn't cause a
>> double free. But as mentioned, I couldn't come up with any case where a
>> passed-in non-NULL list becomes empty, so this shouldn't be necessary.
>> And if it ever does become necessary we'd notice anyway via the leak
>> sanitizer.
>
> Nicely explained.
>
>> Interestingly enough we did not have a single test exercising this
>> branch: all tests pass just fine even when replacing it with a call to
>> `BUG()`. Add a test that exercises it.
>
> Seems reasonable. That test will end up passing an empty list into
> find_bisection(), because everything is UNINTERESTING, and the revision
> machinery's limit_list() removes the UNINTERESTING elements from the
> revs->commits list.
>
> I wondered if a topology more like this:
>
>       one
>       /
>   base--two
>
> could produce something interesting from "rev-list --bisect ^one two".
> But no, we still end up removing all of the uninteresting commits before
> we hit find_bisection(). And anyway, "two" is obviously going to be the
> output, so we know "best" won't be NULL and it won't hit your new code.
>
> So I agree there doesn't seem to be a way to trigger the new code that
> isn't just a noop.
>
> Thanks for fixing this!
Thanks, both of you.  Will queue and merge to 'next'.
Previous: Jeff King
Message 3 of 3 in “bisect: address Coverity warning about potential double free”
  1. bisect: address Coverity warning about potential double freePatrick Steinhardt, Nov 25, 2024
  2. Jeff KingNov 25, 2024
  3. Junio C HamanoNov 26, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.