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

[Bug] hook: -Wanalyzer-deref-before-check warning in run_hooks_opt

From
Ccorrectmost <cmlists@sent.com>
Date
Jan 9, 2026, 01:24 UTC
Message-ID
<72d123b8-b75e-4b1d-8506-95eb9ad350da@app.fastmail.com>
Hi,
GCC 15.2.1 warns about a potential NULL pointer dereference in run_hooks_opt on the master branch:
---
../hook.c: In function ‘run_hooks_opt’:
../hook.c:167:12: error: check of ‘options’ for NULL after already dereferencing it [-Werror=analyzer-deref-before-check]
  167 |         if (!options)
      |            ^
[...snip...]
    │  156 |                 .ungroup = options->ungroup,
    │      |                            ~~~~~~~~~~~~~~~~
    │      |                                   |
    │      |                                   (7) pointer ‘options’ is dereferenced here
    │......
    │  167 |         if (!options)
    │      |            ~                           
    │      |            |
    │      |            (8)   pointer ‘options’ is checked for NULL here but it was already dereferenced at (7)
    │
---
This does seem like a real bug, though I'm not sure how likely it is to occur.  It looks like the warning was introduced in merge commit f406b89552 ("Use hook API to replace ad-hoc invocation of hook scripts with the run_command() API.").
I noticed the warning while compiling commit d529f3a19736 on Arch Linux.
Thanks!
Next: Patrick Steinhardt
Message 1 of 7 in “[Bug] hook: -Wanalyzer-deref-before-check warning in run_hooks_opt”
  1. correctmostJan 9, 2026
  2. Patrick SteinhardtJan 9, 2026
  3. Adrian RatiuJan 9, 2026
  4. Ben KnobleJan 9, 2026
  5. Patrick SteinhardtJan 9, 2026
  6. brian m. carlsonJan 9, 2026
  7. Adrian RatiuJan 11, 2026

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.