Skip to contentSkip to conversation

coverity: Fix g_malloc_n-like models

GIT PULL Applied Markus Armbruster 2 participants 3 messages Mar 17, 2015

lore
Share & tools
lore
#1 lore raw
In reply to Markus Armbruster

From: Jan Kiszka <[email protected]>

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

---
 scripts/coverity-model.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/coverity-model.c +3 -3
index 58356af..cdda259 100644
@@ -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
Signature · 1 line
1.9.3
#0 lore raw

This can safely go into 2.3. I can also wait for 2.4. Your choice.

The following changes since commit 17b11a1406fdc43b5022f32a6fbfcb005a353b38:

Merge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-20150316' into staging (2015-03-16 18:27:13 +0000)

are available in the git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-cov-model-2015-03-17

for you to fetch changes up to 906b8bab8bbc588f19752ed19e0222330dce31f9:

coverity: Fix g_malloc_n-like models (2015-03-17 09:29:39 +0100)

----------------------------------------------------------------
coverity: Fix g_malloc_n-like models

----------------------------------------------------------------
Jan Kiszka (1):
coverity: Fix g_malloc_n-like models

 scripts/coverity-model.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.3
#2 lore raw
Quoted 11 lines · Markus Armbruster

This can safely go into 2.3. I can also wait for 2.4. Your choice.

The following changes since commit 17b11a1406fdc43b5022f32a6fbfcb005a353b38:

Merge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-20150316' into staging (2015-03-16 18:27:13 +0000)

are available in the git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-cov-model-2015-03-17

Quoted 8 lines

for you to fetch changes up to 906b8bab8bbc588f19752ed19e0222330dce31f9:

coverity: Fix g_malloc_n-like models (2015-03-17 09:29:39 +0100)

----------------------------------------------------------------
coverity: Fix g_malloc_n-like models

----------------------------------------------------------------

Applied, thanks.

-- PMM