Commit a44af723 authored by Philippe Mathieu-Daudé's avatar Philippe Mathieu-Daudé Committed by Michael Tokarev

thunk: assert nb_fields is valid

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: 's avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: 's avatarMichael Tokarev <mjt@tls.msk.ru>
parent b929f7e5
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment