1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 03:53:43 +01:00

dwarf: do not allocate in load_debug_frame (#72)

load_debug_frame calls malloc() in a couple spots, use mmap via
GET_MEMORY instead.  These call paths are infrequent, and are never
freed.

Found by running tcmalloc unit tests on aarch64, when DEBUG_FRAME support is on.
This commit is contained in:
Dave Watson 2018-04-10 10:55:34 -07:00 committed by GitHub
parent c91974f30f
commit b5cbcaee13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -119,7 +119,7 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local)
}
*bufsize = shdr->sh_size;
*buf = malloc (*bufsize);
GET_MEMORY(*buf, *bufsize);
memcpy(*buf, shdr->sh_offset + ei.image, *bufsize);
@ -208,7 +208,7 @@ locate_debug_info (unw_addr_space_t as, unw_word_t addr, const char *dlname,
if (!err)
{
fdesc = malloc (sizeof (struct unw_debug_frame_list));
GET_MEMORY(fdesc, sizeof (struct unw_debug_frame_list));
fdesc->start = start;
fdesc->end = end;