DWARF: handle out of memory errors
@@ -141,7 +141,15 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local,
if (chdr->ch_type == ELFCOMPRESS_ZLIB)
{
*bufsize = destSize = chdr->ch_size;
+
GET_MEMORY (*buf, *bufsize);
+ if (!*buf)
+ {
+ Debug (2, "failed to allocate zlib .debug_frame buffer, skipping\n");
+ munmap(ei.image, ei.size);
+ return 1;
+ }
+
ret = uncompress((unsigned char *)*buf, &destSize,
shdr->sh_offset + ei.image + sizeof(*chdr),
shdr->sh_size - sizeof(*chdr));
@@ -169,7 +177,14 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local,
{
#endif
*bufsize = shdr->sh_size;
+
GET_MEMORY (*buf, *bufsize);
+ if (!*buf)
+ {
+ Debug (2, "failed to allocate .debug_frame buffer, skipping\n");
+ munmap(ei.image, ei.size);
+ return 1;
+ }
memcpy(*buf, shdr->sh_offset + ei.image, *bufsize);
@@ -277,6 +292,11 @@ locate_debug_info (unw_addr_space_t as, unw_word_t addr, unw_word_t segbase,
if (!err)
{
GET_MEMORY (fdesc, sizeof (struct unw_debug_frame_list));
+ if (!fdesc)
+ {
+ Debug (2, "failed to allocate frame list entry\n");
+ return 0;
+ }
fdesc->start = start;
fdesc->end = end;
