[PATCH] res_query: fix for CNAME responses on A queries.

Kevin Day thekevinday at gmail.com
Sat Nov 28 07:19:58 UTC 2009


On Sat, Nov 28, 2009 at 1:06 AM, Kevin Day <thekevinday at gmail.com> wrote:
> On Fri, Nov 27, 2009 at 2:45 PM, Rob Landley <rob at landley.net> wrote:
>> On Friday 27 November 2009 11:45:50 Kevin Day wrote:
>>> I was looking at uClibc 0.9.28.3 to try and apply this patch and noticed:
>>>
>>> At the very end of your patch, the untouched code only has
>>> free(packet); while 0.9.28.3 has:
>>>         if (packet)
>>>                 free(packet);
>>>
>>> Does anybody know why was this safety check removed?
>>
>> From the Single Unix Specification version 4 (I.E. SUSv4, I.E. POSIX 2008):
>>
>>  http://www.opengroup.org/onlinepubs/9699919799/functions/free.html
>>
>>  > If ptr is a null pointer, no action shall occur.
>>
>> I.E. free() has a null check built-in, as required by POSIX.
>>
>> Rob
>> --
>> Latency is more important than throughput. It's that simple. - Linus Torvalds
>>
>
> So you are saying a double-free cannot happen here?
>
> --
> Kevin Day
>
Never mind, I just remember that I have habits and practices that I
have engraved into myself such that I forget the internal details
sometimes.

I generally have a free(..) wrapper that frees the pointer and then
sets the pointer to null so that the double free doesn't happen. And
then out of what I would call paranoia practice I always wrap them in
if (pointer) anyway.

So my concern was if those pointers were freed already and if they
were being set to NULL after they were being freed to prevent double
frees.

Sorry for the double post, it just popped into my mind after I hit the
send button.


-- 
Kevin Day


More information about the uClibc mailing list