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

Re: clang static analyzer

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 7, 2009, 00:26 UTC
Message-ID
<7vpr6rd3ye.fsf@alter.siamese.dyndns.org>
In-Reply-To
<33ABC714-2BCC-4910-BCAE-D331AAF2A724@dbservice.com>
Tomas Carnecky <tom@dbservice.com> writes:
> xdiff-interface.c:xdiff_set_find_func() - When 'value' is a string with
> no newline character in it, the loop at line 291 sets 'value' to NULL on
> its first iteration and then passes 'value' to strchr() in the second
> iteration.
Thanks, but I am confused with your analysis.

If value doesn't have '\n', then regs->nr is 1 when you go into the loop at ll. 291-, because we counted the number of LF in the first loop in the function.

The first iteration of the second loop sets ep to NULL, expression is set to value, then we run regcomp on the expression. Then at the end of the loop we do set value to a bogus "(char*)1". But incrementing i makes it go over regs->nr and satisfy the termination condition of the loop; we happily exit the loop before we use the now bogus "value".

Previous: Junio C Hamano
Message 7 of 7 in “clang static analyzer”
  1. Tomas CarneckyDec 6, 2009
  2. Jeff KingDec 6, 2009
  3. Nicolas PitreDec 6, 2009
  4. Jeff KingDec 6, 2009
  5. Nicolas SebrechtDec 6, 2009
  6. Junio C HamanoDec 7, 2009
  7. Junio C HamanoDec 7, 2009

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.