mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-27 13:31:02 +08:00
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
This commit is contained in:
parent
f49fabead4
commit
24182d859f
@ -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 },
|
||||
|
Loading…
x
Reference in New Issue
Block a user