Avoid `free(3)`ing invalid pointer

Fixes [Bug #17794]
This commit is contained in:
xtkoba 2021-04-29 23:53:55 +09:00 committed by Jeremy Evans
parent b7d01b0d1b
commit d795f494a8
Notes: git 2021-06-29 06:07:03 +09:00
1 changed files with 2 additions and 0 deletions

View File

@ -1699,6 +1699,7 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
static unsigned long
uncompress_debug_section(ElfW(Shdr) *shdr, char *file, char **ptr)
{
*ptr = NULL;
#ifdef SUPPORT_COMPRESSED_DEBUG_LINE
ElfW(Chdr) *chdr = (ElfW(Chdr) *)(file + shdr->sh_offset);
unsigned long destsize = chdr->ch_size;
@ -1719,6 +1720,7 @@ uncompress_debug_section(ElfW(Shdr) *shdr, char *file, char **ptr)
fail:
free(*ptr);
*ptr = NULL;
#endif
return 0;
}