On 10/02/12 02:28, Marc-André Moreau wrote :
> On Thu, Feb 9, 2012 at 8:14 PM, Jay Sorg <jay.s...@gmail.com> wrote:
> 
>> I see this in a commit to memory.c
>>
>> "Besides "ptr=NULL; free(ptr);" does nothing so no need to check for
>> NULL in xfree()"
>>
>> This is not true, free(NULL); is undefined and can crash!
>> I think we have to put the if (ptr != NULL) back in xfree in memory.c.
>> Or change everywhere that might pass NULL.
>>
> 
> There was some discussion on IRC about that, it turns out that the C
> standard actually defines that nothing happens on free(NULL), but that a
> tiny minority of compilers may not comply with the standard in that regard:
> http://stackoverflow.com/questions/1938735/does-freeptr-where-ptr-is-null-corrupt-memory
> 
> I honestly don't mind putting it back in. I'll put it back right now

Sorry about that.

When I made that commit I honestly thought about what I was taught back in 
school (i.e. the C standard: "If ptr is a null pointer, no action occurs").

Didn't know there were (still ?) some (very old ?) non-standard-compliant 
compilers for such a basic thing.

Alexis

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Freerdp-devel mailing list
Freerdp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freerdp-devel

Reply via email to