Re: [PATCH] list-objects: perform NULL check before the variable is dereferenced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyen Thai Ngoc Duy <pclouds@xxxxxxxxx> writes:

> 2012/4/10 Junio C Hamano <gitster@xxxxxxxxx>:
>> Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:
>>
>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
>>> ---
>>>  list-objects.c |   10 ++++++----
>>>  1 files changed, 6 insertions(+), 4 deletions(-)
>>
>> Please explain why this is needed?
>>
>> I can see that process_blob() is called from process_tree() which passes
>> the return value from lookup_blob(entry.sha1) directly without looking at
>> it.  lookup_blob() can issue an error message and return NULL if there is
>> a SHA-1 collision with an object that is not a blob.
>
> to avoid segmentation fault in that case, if "blob" is NULL, it dies
> at blob->object anyway and the check "if (!obj)" is useless.

Well, I didn't mean that you should explain whatever to _me_ as a
response; I meant that the log message should explain that to future
readers. I thought you have been here long enough to know that ;-)

Also "check NULL before dereferencing" means "avoid segmentation fault",
so that is not the primary thing that needs to be explained.  The point is
to explain why and how a NULL could come into the codepath in the first
place.

Please try again when post 1.7.10 cycle opens.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]