On 08/27/2014 05:12 PM, Lukas Slebodnik wrote:
On (27/08/14 17:10), Pavel Reichl wrote:
> On 08/27/2014 10:09 AM, Lukas Slebodnik wrote:
>> ehlo,
>>
>> warning reported by coverity
>>
>> patch is attached
>>
>> LS
> As I understand the code there is no way that 0 could be passed as second
> argument to the realloc call, right? Because that would lead to freeing same
> memory twice.
>
> Would it be more defensive approach to test for zero argument explicitly?
> What do you think Lukas?
>
No,
NULL can be returned if there is not memory for allocation (ENOMEM).
For example you will try to allocate 2^31 bytes
LS
NULL can be also returned if you pass 0 as the size parameter, which
would in our case lead to calling free on the same pointer twice, which
is baaaad!
If you are explicitly interested in ENOMEM case, you may consider
checking value of errno.
Still I think it is better to test value of size parameter.
_______________________________________________
sssd-devel mailing list
sssd-devel(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel