std.cfg: Add "buffer-size" attribute and tests for aligned_alloc().
This commit is contained in:
parent
55433fce40
commit
316475f79f
|
@ -7312,7 +7312,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
|||
<memory>
|
||||
<alloc init="false" buffer-size="malloc">malloc</alloc>
|
||||
<alloc init="true" buffer-size="calloc">calloc</alloc>
|
||||
<alloc init="false">aligned_alloc</alloc>
|
||||
<alloc init="false" buffer-size="malloc:2">aligned_alloc</alloc>
|
||||
<dealloc>free</dealloc>
|
||||
</memory>
|
||||
<resource>
|
||||
|
|
|
@ -75,6 +75,12 @@ void bufferAccessOutOfBounds(void)
|
|||
fwrite(a,1,5,stdout);
|
||||
// cppcheck-suppress bufferAccessOutOfBounds
|
||||
fread(a,1,6,stdout);
|
||||
|
||||
char * pAlloc1 = aligned_alloc(8, 16);
|
||||
memset(pAlloc1, 0, 16);
|
||||
// cppcheck-suppress bufferAccessOutOfBounds
|
||||
memset(pAlloc1, 0, 17);
|
||||
free(pAlloc1);
|
||||
}
|
||||
|
||||
void bufferAccessOutOfBounds_libraryDirectionConfiguration(void)
|
||||
|
@ -89,6 +95,15 @@ void bufferAccessOutOfBounds_libraryDirectionConfiguration(void)
|
|||
arr[c] = 'x';
|
||||
}
|
||||
|
||||
void arrayIndexOutOfBounds()
|
||||
{
|
||||
char * pAlloc1 = aligned_alloc(8, 16);
|
||||
pAlloc1[15] = '\0';
|
||||
// cppcheck-suppress arrayIndexOutOfBounds
|
||||
pAlloc1[16] = '1';
|
||||
free(pAlloc1);
|
||||
}
|
||||
|
||||
// memory leak
|
||||
|
||||
void ignoreleak(void)
|
||||
|
|
Loading…
Reference in New Issue