gnu.cfg: Add "buffer-size" attribute and tests for xcalloc().
This commit is contained in:
parent
316475f79f
commit
7c09b0cfe0
|
@ -10,7 +10,7 @@
|
|||
</memory>
|
||||
<memory>
|
||||
<alloc init="false" buffer-size="malloc">xmalloc</alloc>
|
||||
<alloc init="true">xcalloc</alloc>
|
||||
<alloc init="true" buffer-size="calloc">xcalloc</alloc>
|
||||
<dealloc>free</dealloc>
|
||||
</memory>
|
||||
<!-- https://linux.die.net/man/3/backtrace -->
|
||||
|
|
|
@ -63,6 +63,14 @@ void bufferAccessOutOfBounds()
|
|||
sethostname(buf, 2);
|
||||
// cppcheck-suppress bufferAccessOutOfBounds
|
||||
sethostname(buf, 4);
|
||||
|
||||
// Declaration necessary because there is no specific / portable header containing xcalloc.
|
||||
extern void *xcalloc(size_t nmemb, size_t size);
|
||||
char * pAlloc1 = xcalloc(2, 4);
|
||||
memset(pAlloc1, 0, 8);
|
||||
// cppcheck-suppress bufferAccessOutOfBounds
|
||||
memset(pAlloc1, 0, 9);
|
||||
free(pAlloc1);
|
||||
}
|
||||
|
||||
void leakReturnValNotUsed()
|
||||
|
|
Loading…
Reference in New Issue