Commit e03c352f authored by lahiker42's avatar lahiker42

Do not crash if def_bd == NULL (!)

Patch by Andrei Nigmatulin.


git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@266 00440858-1255-0410-a3e6-75ea37f81c3a
parent 3695444f
0.15 (NOT YET RELEASED) 0.15 (NOT YET RELEASED)
- make protobuf_c_message_init() into a function (Issue #49, daveb) - make protobuf_c_message_init() into a function (Issue #49, daveb)
- Fix for freeing memory after unpacking bytes w/o a default-value.
(Andrei Nigmatulin)
0.14: 0.14:
- build fix (missing dependency in test directory) - build fix (missing dependency in test directory)
......
...@@ -1751,7 +1751,9 @@ parse_required_member (ScannedMember *scanned_member, ...@@ -1751,7 +1751,9 @@ parse_required_member (ScannedMember *scanned_member,
const ProtobufCBinaryData *def_bd; const ProtobufCBinaryData *def_bd;
unsigned pref_len = scanned_member->length_prefix_len; unsigned pref_len = scanned_member->length_prefix_len;
def_bd = scanned_member->field->default_value; def_bd = scanned_member->field->default_value;
if (maybe_clear && bd->data != NULL && bd->data != def_bd->data) if (maybe_clear
&& bd->data != NULL
&& (def_bd == NULL || bd->data != def_bd->data))
FREE (allocator, bd->data); FREE (allocator, bd->data);
DO_ALLOC (bd->data, allocator, len - pref_len, return 0); DO_ALLOC (bd->data, allocator, len - pref_len, return 0);
memcpy (bd->data, data + pref_len, len - pref_len); memcpy (bd->data, data + pref_len, len - pref_len);
......
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