[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 18/25] thunk: assert nb_fields is valid
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 18/25] thunk: assert nb_fields is valid |
Date: |
Mon, 31 Jul 2017 13:21:37 +0300 |
From: Philippe Mathieu-Daudé <address@hidden>
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>
Signed-off-by: Michael Tokarev <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.11.0
- [Qemu-trivial] [PULL 10/25] qcow2: fix null pointer dereference, (continued)
- [Qemu-trivial] [PULL 10/25] qcow2: fix null pointer dereference, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 09/25] ivshmem: fix incorrect error handling in ivshmem_recv_msg(), Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 02/25] fix qemu-system-unicore32 crashing when calling without -kernel, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 07/25] tests: add missing dependency to build QTEST_QEMU_BINARY, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 04/25] tests: test-netfilter && pxe-test require slirp, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 12/25] net/eth: fix incorrect check of iov_to_buf() return value, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 13/25] m68k/translate: fix incorrect copy/paste, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 16/25] syscall: fix use of uninitialized values, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 19/25] docs: fix broken paths to docs/interop dir, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 08/25] loader: check get_image_size() return value, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 18/25] thunk: assert nb_fields is valid,
Michael Tokarev <=
- [Qemu-trivial] [PULL 17/25] syscall: check inotify() and eventfd() return value, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 03/25] MAINTAINERS: Improve the NetBSD regex pattern, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 22/25] docs: fix broken paths to docs/devel/atomics.txt, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 11/25] ui/vnc: fix leak of SocketAddress **, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 21/25] docs: fix broken paths to docs/devel/qapi-code-gen.txt, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 20/25] docs: fix broken paths to docs/interop/qcow2.txt, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 15/25] syscall: fix dereference of undefined pointer, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 25/25] docs: fix broken paths to docs/specs/ivshmem-spec.txt, Michael Tokarev, 2017/07/31
- [Qemu-trivial] [PULL 14/25] linux-user/sh4: fix incorrect memory write, Michael Tokarev, 2017/07/31