On 5/25/2012 11:25 AM, Ken Goldman wrote:
> On 5/25/2012 11:03 AM, Steffen DETTMER wrote:
>>
>> I think crashing with NULL is quite good: a must-not-happen situation
>> leads to a defined dead of SIGSEGVs, at least for platforms supporting
>> that, typically with good aid for debuggin (like core files or halting
>> debuggers providing a backtrace). Maybe adding an assert() before.
>
> That's not the normal library behavior.
>
> My typical design pattern is:
>
> void *ptr = NULL;
> do stuff which may in some branches allocate the pointer
> free(ptr);
>
> If the library crashes on free(NULL), you're just making people like me
> do this everywhere:
>
> if (ptr != NULL) free (ptr);

Any secure programming standard would also require that you set ptr to NULL as
soon as you free it.
Re-using already freed memory pointers is a common source of both bugs and
security holes.
>
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
> .
>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to