+2020-05-08 Mark Wielaard <mark@klomp.org>
+
+ * libdwfl/core-file.c (dwfl_core_file_report): Keep track of
+ new bool cleanup_user_core and cleanup dwfl->user_core in error
+ case.
+
2020-04-30 Mark Wielaard <mark@klomp.org>
* find-debuginfo.c (dwfl_standard_find_debuginfo): When mod->dw
return -1;
}
+ bool cleanup_user_core = false;
if (dwfl->user_core != NULL)
free (dwfl->user_core->executable_for_core);
if (executable == NULL)
{
if (dwfl->user_core == NULL)
{
+ cleanup_user_core = true;
dwfl->user_core = calloc (1, sizeof (struct Dwfl_User_Core));
if (dwfl->user_core == NULL)
{
dwfl->user_core->executable_for_core = strdup (executable);
if (dwfl->user_core->executable_for_core == NULL)
{
+ if (cleanup_user_core)
+ {
+ free (dwfl->user_core);
+ dwfl->user_core = NULL;
+ }
__libdwfl_seterrno (DWFL_E_NOMEM);
return -1;
}
GElf_Phdr notes_phdr;
int ndx = dwfl_report_core_segments (dwfl, elf, phnum, ¬es_phdr);
if (unlikely (ndx <= 0))
- return ndx;
+ {
+ if (cleanup_user_core)
+ {
+ free (dwfl->user_core->executable_for_core);
+ free (dwfl->user_core);
+ dwfl->user_core = NULL;
+ }
+ return ndx;
+ }
/* Next, we should follow the chain from DT_DEBUG. */