public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [Bug] hook: -Wanalyzer-deref-before-check warning in run_hooks_opt
@ 2026-01-09  1:24 correctmost
  2026-01-09 11:31 ` Patrick Steinhardt
  0 siblings, 1 reply; 7+ messages in thread
From: correctmost @ 2026-01-09  1:24 UTC (permalink / raw)
  To: git

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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-11 14:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09  1:24 [Bug] hook: -Wanalyzer-deref-before-check warning in run_hooks_opt correctmost
2026-01-09 11:31 ` Patrick Steinhardt
2026-01-09 12:33   ` Adrian Ratiu
2026-01-09 16:02   ` Ben Knoble
2026-01-09 16:18     ` Patrick Steinhardt
2026-01-09 22:18   ` brian m. carlson
2026-01-11 14:20     ` Adrian Ratiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox