coverity: Fix g_malloc_n-like models

Allocate the calculated overall size, not only the size of a single
element.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
master
Jan Kiszka 2015-03-12 12:24:26 +01:00 committed by Markus Armbruster
parent 17b11a1406
commit 906b8bab8b
1 changed files with 3 additions and 3 deletions

View File

@ -123,7 +123,7 @@ void *g_malloc_n(size_t nmemb, size_t size)
__coverity_negative_sink__(nmemb);
__coverity_negative_sink__(size);
sz = nmemb * size;
ptr = __coverity_alloc__(size);
ptr = __coverity_alloc__(sz);
__coverity_mark_as_uninitialized_buffer__(ptr);
__coverity_mark_as_afm_allocated__(ptr, "g_free");
return ptr;
@ -137,7 +137,7 @@ void *g_malloc0_n(size_t nmemb, size_t size)
__coverity_negative_sink__(nmemb);
__coverity_negative_sink__(size);
sz = nmemb * size;
ptr = __coverity_alloc__(size);
ptr = __coverity_alloc__(sz);
__coverity_writeall0__(ptr);
__coverity_mark_as_afm_allocated__(ptr, "g_free");
return ptr;
@ -151,7 +151,7 @@ void *g_realloc_n(void *ptr, size_t nmemb, size_t size)
__coverity_negative_sink__(size);
sz = nmemb * size;
__coverity_escape__(ptr);
ptr = __coverity_alloc__(size);
ptr = __coverity_alloc__(sz);
/*
* Memory beyond the old size isn't actually initialized. Can't
* model that. See Coverity's realloc() model