[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for 2.10 v2 15/20] thunk: assert nb_fields is valid
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH for 2.10 v2 15/20] thunk: assert nb_fields is valid |
Date: |
Wed, 26 Jul 2017 23:42:20 -0300 |
thunk.c:91:32: warning: Call to 'malloc' has an allocation size of 0 bytes
se->field_offsets[i] = malloc(nb_fields * sizeof(int));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
thunk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/thunk.c b/thunk.c
index 2dac36666d..d5d8645cd4 100644
--- a/thunk.c
+++ b/thunk.c
@@ -67,7 +67,6 @@ void thunk_register_struct(int id, const char *name, const
argtype *types)
int nb_fields, offset, max_align, align, size, i, j;
assert(id < max_struct_entries);
- se = struct_entries + id;
/* first we count the number of fields */
type_ptr = types;
@@ -76,6 +75,8 @@ void thunk_register_struct(int id, const char *name, const
argtype *types)
type_ptr = thunk_type_next(type_ptr);
nb_fields++;
}
+ assert(nb_fields > 0);
+ se = struct_entries + id;
se->field_types = types;
se->nb_fields = nb_fields;
se->name = name;
--
2.13.3
- [Qemu-devel] [PATCH for 2.10 v2 08/20] vfio/platform: fix use of freed memory, (continued)
- [Qemu-devel] [PATCH for 2.10 v2 08/20] vfio/platform: fix use of freed memory, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 09/20] vfio/pci: fix use of freed memory, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 10/20] m68k/translate: fix incorrect copy/paste, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 11/20] linux-user/sh4: fix incorrect memory write, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 12/20] syscall: fix dereference of undefined pointer, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 13/20] syscall: fix use of uninitialized values, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 14/20] syscall: check inotify() and eventfd() return value, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 15/20] thunk: assert nb_fields is valid,
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH for 2.10 v2 17/20] bt-sdp: fix memory leak in sdp_service_record_build(), Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 18/20] 9pfs: avoid sign conversion error simplifying the code, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 19/20] spapr_vio: fix overflow of qdevs in spapr_dt_vdevice(), Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-devel] [PATCH for 2.10 v2 20/20] i2c/exynos4210: fix write to I2CADD register, bit 0 is not mapped, Philippe Mathieu-Daudé, 2017/07/26