On 26 July 2012 12:14, Michael Stapelberg <[email protected]> wrote:
> Quoting Mateusz Loskot (2012-07-13 20:06:58)
>> > 1) You are not using FREE(last_urgent_ws);, but free(last_urgent_ws) in
>> >    line 1489, which is unsafe (it is not guaranteed that last_urgent_ws
>> >    is != NULL).
>>
>> There is no such guarantee needed for free() as per the C99 Standard:
>>
>> 7.20.3.2 The free function
>> 2 The free function causes the space pointed to by ptr to be
>> deallocated, that is, made
>> available for further allocation. If ptr is a null pointer, no action occurs.
> I think you misunderstood me. What FREE does is it sets the pointer to
> NULL after calling free(). Therefore, the following code works fine:
>
>     FREE(last_urgent_ws);
>     // …things happen here, and much later:
>     FREE(last_urgent_ws);
>
> While the following is not:
>
>     free(last_urgent_ws);
>     // …things happen here, and much later:
>     free(last_urgent_ws); // points to an old memory location

Michael,

Yes, it looks I confused things.
You're perfectly right here.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net

Reply via email to