Set the defaults properly for newly allocated submessages.
Also, pb_dec_submessage() should have used calloc() instead of malloc() in the first place. git-svn-id: https://svn.kapsi.fi/jpa/nanopb-dev@1083 e3a754e5-d11d-0410-8d38-ebb782a927b9
This commit is contained in:
committed by
Petteri Aimonen
parent
f7c8dd81d4
commit
ba93b65e9f
@@ -661,10 +661,11 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
|
||||
#ifdef MALLOC_HEADER
|
||||
if (*(void**)dest == NULL)
|
||||
{
|
||||
void *object = malloc(msg->size);
|
||||
void *object = calloc(1, msg->size);
|
||||
if (!object)
|
||||
return false;
|
||||
*(void**)dest = object;
|
||||
pb_message_set_to_defaults(msg, object);
|
||||
dest = object;
|
||||
} else {
|
||||
dest = *(void**)dest;
|
||||
|
||||
Reference in New Issue
Block a user