protobuf-c: parse_required_member(): zero bd->data in 0-length byte string case

in the case that we are unpacking a 0-length byte string, we need to
explicitly set bd->data to NULL, otherwise we may try to free() a stray
pointer when protobuf_c_message_free_unpacked() is called on the
containing message.

(Issue #157.)
This commit is contained in:
Robert Edmonds 2014-08-05 14:20:29 -04:00
parent 4c2225d0a7
commit 108635a35f

View File

@ -2304,6 +2304,8 @@ parse_required_member(ScannedMember *scanned_member,
if (bd->data == NULL)
return FALSE;
memcpy(bd->data, data + pref_len, len - pref_len);
} else {
bd->data = NULL;
}
bd->len = len - pref_len;
return TRUE;