mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-27 13:31:02 +08:00
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:
parent
4c2225d0a7
commit
108635a35f
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user