]> git.proxmox.com Git - mirror_qemu.git/commitdiff
coverity: Fix g_malloc_n-like models
authorJan Kiszka <jan.kiszka@siemens.com>
Thu, 12 Mar 2015 11:24:26 +0000 (12:24 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 17 Mar 2015 08:29:39 +0000 (09:29 +0100)
Allocate the calculated overall size, not only the size of a single
element.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
scripts/coverity-model.c

index 58356afa66e9b5c2680f406a06ba9afc3f6fdba4..cdda2591d9469ce11a930550295697138cb5eacf 100644 (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