diff options
author | Sergey Korolev <s.korolev@ndmsystems.com> | 2021-07-03 00:34:20 +0300 |
---|---|---|
committer | Dave Watson <dade.watson@gmail.com> | 2021-07-06 11:52:04 -0700 |
commit | 441320a0486827ce4f167ac456981eba19abd062 (patch) | |
tree | 05bd78ac16840564b469f2da215152cce1ab0463 | |
parent | 0af7e7a53480ce8e1cf6cfb4e9fe071c1185ef31 (diff) | |
download | libunwind-441320a0486827ce4f167ac456981eba19abd062.tar.gz |
DWARF: handle out of memory errors
-rw-r--r-- | src/dwarf/Gfind_proc_info-lsb.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/dwarf/Gfind_proc_info-lsb.c b/src/dwarf/Gfind_proc_info-lsb.c index 1f48714e..7f170915 100644 --- a/src/dwarf/Gfind_proc_info-lsb.c +++ b/src/dwarf/Gfind_proc_info-lsb.c @@ -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); + + 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); + + 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); @@ -276,7 +291,12 @@ 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)); + 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; |