Thread (7 messages) flat view 7 messages, 5 authors, 2026-01-11

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

From: correctmost <hidden>
Date: 2026-01-09 01:25:06

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!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help