Wiki Markup |
---|
When the requested size is zero the behavior of the memory allocation functions {{malloc()}}, {{calloc()}}, and {{realloc()}} is [implementation-defined|BB. Definitions#implementation-defined behavior]. According to C99 Section 7.20.3 \[[ISO/IEC 9899:1999|AA. References#ISOBibliography#ISO/IEC 9899-1999]\]: |
If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object.
...
Wiki Markup |
---|
\[[Vanegue 10|AA. References#VanegueBibliography#Vanegue 10]\] Julien Vanegue. [Automated vulnerability analysis of zero sized heap allocations|http://hackitoergosum.org/wp-content/uploads/2010/04/HES10-jvanegue_zero-allocations.pdf]. April 2010. \[[ISO/IEC 9899:1999|AA. References#ISOBibliography#ISO/IEC 9899-1999]\] Section 7.20.3, "Memory Management Functions" \[[MITRE 07|AA. References#MITREBibliography#MITRE 07]\] [CWE ID 687|http://cwe.mitre.org/data/definitions/687.html], "Function Call With Incorrectly Specified Argument Value" \[[Seacord 05|AA. References#SeacordBibliography#Seacord 05]\] Chapter 4, "Dynamic Memory Management" |
...