]> git.ipfire.org Git - thirdparty/git.git/commit
hook: check for NULL pointer before deref
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Fri, 9 Jan 2026 18:19:12 +0000 (20:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jan 2026 21:10:30 +0000 (13:10 -0800)
commit465c604cef62a228d3699d89b8568ab8ab80da74
tree3ce06b4ecce1feb411dc5effd240da9bcd57fc38
parent60a803639d37ecfae4906522b4692b68c821dc14
hook: check for NULL pointer before deref

Fix a compiler warning (-Werror=analyzer-deref-before-check) due to
dereferencing the options pointer before NULL checking it.

In practice run_hooks_opt() is never called with a NULL opt struct,
so this just fixes the code to not trigger the warning anymore.

The NULL check is kept as-is because some future patches might end up
calling run_hooks_opt with a NULL opt struct, which is clearly a bug.

While at it, also fix the BUG message function name.

Reported-by: correctmost <cmlists@sent.com>
Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hook.c