[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models |
Date: |
Thu, 12 Mar 2015 12:24:26 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
Allocate the calculated overall size, not only the size of a single
element.
Signed-off-by: Jan Kiszka <address@hidden>
---
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
- [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models,
Jan Kiszka <=