Commit 24182d85 authored by Oleg Efimov's avatar Oleg Efimov

protobuf-c.c: Better input checks in protobuf_c_message_free_unpacked

Check for NULL message pointer passed to protobuf_c_message_free_unpacked

Closes #177
parent f49fabea
......@@ -3158,10 +3158,14 @@ void
protobuf_c_message_free_unpacked(ProtobufCMessage *message,
ProtobufCAllocator *allocator)
{
if (message == NULL)
return;
const ProtobufCMessageDescriptor *desc = message->descriptor;
unsigned f;
ASSERT_IS_MESSAGE(message);
if (allocator == NULL)
allocator = &protobuf_c__allocator;
message->descriptor = NULL;
......
......@@ -1925,6 +1925,12 @@ test_alloc_fail (void)
free (packed);
}
static void
test_free_unpacked_input_check_for_null_message (void)
{
protobuf_c_message_free_unpacked (NULL, NULL);
}
/* This test checks that protobuf decoder is capable of detecting special
cases of incomplete messages. The message should have at least two required
fields field1 and field129 with positions pos1 and pos2 (no matter what the
......@@ -2225,6 +2231,8 @@ static Test tests[] =
{ "test free unpacked", test_alloc_free_all },
{ "test alloc failure", test_alloc_fail },
{ "test free unpacked input check for null message", test_free_unpacked_input_check_for_null_message },
{ "test required_fields_bitmap", test_required_fields_bitmap },
{ "test field flags", test_field_flags },
......
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