pidgin/pidgin

Gadu-Gadu: fix protobuf-c undefined behaviour. Fixes #16327
release-2.x.y
2014-10-12, Tomasz Wasilczyk
1a8a6a18e76e
Gadu-Gadu: fix protobuf-c undefined behaviour. Fixes #16327
--- a/libpurple/protocols/gg/lib/protobuf-c.c Tue Sep 30 07:39:51 2014 -0700
+++ b/libpurple/protocols/gg/lib/protobuf-c.c Sun Oct 12 19:53:18 2014 +0200
@@ -218,6 +218,8 @@
while (new_alloced < new_len)
new_alloced += new_alloced;
DO_ALLOC (new_data, &protobuf_c_default_allocator, new_alloced, return);
+ if (!new_data)
+ return;
memcpy (new_data, simp->data, simp->len);
if (simp->must_free_data)
FREE (&protobuf_c_default_allocator, simp->data);
@@ -2059,6 +2061,8 @@
ufield->wire_type = scanned_member->wire_type;
ufield->len = scanned_member->len;
DO_UNALIGNED_ALLOC (ufield->data, allocator, scanned_member->len, return 0);
+ if (ufield->data == NULL)
+ return 0;
memcpy (ufield->data, scanned_member->data, ufield->len);
return 1;
}