Commit f2c1600
committed
bisect: handle NULL commit in bisect_successful()
bisect_successful() calls lookup_commit_reference_by_name() to
find the first bad commit, then immediately passes the result to
repo_format_commit_message() and dereferences commit->object.oid
without checking for NULL.
lookup_commit_reference_by_name() can return NULL when the ref
does not resolve to a valid commit object (e.g., the bisect ref
points to a corrupted or missing object). In that case,
repo_format_commit_message(NULL, ...) and commit->object.oid are
undefined behavior.
In practice this is unlikely because bisect_successful() is only
called after a successful bisect run has identified the bad
commit, but the ref could still become dangling due to a
concurrent gc or repository corruption.
Add a NULL check and return an error if the commit cannot be
looked up.
Pointed out by Coverity.
Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent c087ba6 commit f2c1600
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
663 | 668 | | |
664 | 669 | | |
665 | 670 | | |
| |||
0 commit comments