Thread (23 messages) 23 messages, 5 authors, 2025-08-20

Re: Potential Null Pointer Dereference detected by static analysis tool

From: Phillip Wood <hidden>
Date: 2025-08-13 13:19:18

Hi Cheng

On 13/08/2025 01:23, Cheng wrote:

line 326 in builtin/describe.cdescribe.c, which is located in the function describe_commit. In the following code, cmit could be NULL passed to the call, which then causes a NULL dereference. Seems should be replaced lookup_commit_reference with lookup_commit_or_die.

cmit = lookup_commit_reference(the_repository, oid);
n = find_commit_name(&cmit->object.oid);
     


The NULL value seems to come from function lookup_commit_reference_gently where:

- 1. call to deref_tag may return NULL.

- 2. call to object_as_type may return NULL.


In this repository,  other calls  lookup_commit_reference are followed by a null check. So this seems to lead to NULL dereference. Can I confirm with you whether this is a true positive bug report?
I had a quick look at the callers of describe_commit() and they all seem 
to use an oid that they get from looking up a commit so I'm not sure 
under what circumstances this call to lookup_commit_reference() can fail.

Thanks

Phillip
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help