From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW1E9-00063K-GM for qemu-devel@nongnu.org; Thu, 12 Mar 2015 07:24:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW1E6-00053V-6b for qemu-devel@nongnu.org; Thu, 12 Mar 2015 07:24:33 -0400 Received: from thoth.sbs.de ([192.35.17.2]:53147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW1E5-00052m-T8 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 07:24:30 -0400 Message-ID: <5501776A.20202@siemens.com> Date: Thu, 12 Mar 2015 12:24:26 +0100 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models Reply-To: qemu-trivial List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , qemu-devel , Markus Armbruster Allocate the calculated overall size, not only the size of a single element. Signed-off-by: Jan Kiszka --- scripts/coverity-model.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/coverity-model.c b/scripts/coverity-model.c index 58356af..cdda259 100644 --- a/scripts/coverity-model.c +++ b/scripts/coverity-model.c @@ -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 -- 2.1.4