mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-07-01 06:41:51 -04:00
tests: Fix some memory leaks in testcases.
Make sure all structures allocated in the testcases are disposed so running them under valgrind will show no memory leaks. Signed-off-by: Mark Wielaard <mjw@redhat.com>
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
2015-12-01 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* test-flag-nobits.c (main): Call elf_end.
|
||||
* rerequest_tag.c (main): Call dwarf_end.
|
||||
* funcscopes.c (handle_function): Free scopes.
|
||||
* dwarf-getstring.c (main): Call dwarf_end.
|
||||
* allregs.c (main): Free state.info.
|
||||
* alldts.c (main): Free dyn.
|
||||
* addrcfi.c (handle_address): Free stuff.frame between handle_cfi
|
||||
calls.
|
||||
* addrscopes.c (handle_address): Free scopes.
|
||||
|
||||
2015-10-16 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* Makefile.am [BUILD_STATIC] (libdw): Add -lz.
|
||||
|
||||
+13
-4
@@ -160,10 +160,19 @@ handle_address (GElf_Addr pc, Dwfl *dwfl)
|
||||
Dwfl_Module *mod = dwfl_addrmodule (dwfl, pc);
|
||||
|
||||
struct stuff stuff;
|
||||
return (handle_cfi (dwfl, ".eh_frame",
|
||||
dwfl_module_eh_cfi (mod, &stuff.bias), pc, &stuff)
|
||||
& handle_cfi (dwfl, ".debug_frame",
|
||||
dwfl_module_dwarf_cfi (mod, &stuff.bias), pc, &stuff));
|
||||
stuff.frame = NULL;
|
||||
stuff.bias = 0;
|
||||
int res = handle_cfi (dwfl, ".eh_frame",
|
||||
dwfl_module_eh_cfi (mod, &stuff.bias), pc, &stuff);
|
||||
free (stuff.frame);
|
||||
|
||||
stuff.frame = NULL;
|
||||
stuff.bias = 0;
|
||||
res &= handle_cfi (dwfl, ".debug_frame",
|
||||
dwfl_module_dwarf_cfi (mod, &stuff.bias), pc, &stuff);
|
||||
free (stuff.frame);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -134,6 +134,7 @@ handle_address (GElf_Addr pc, Dwfl *dwfl)
|
||||
|
||||
print_vars (indent + INDENT, die);
|
||||
}
|
||||
free (scopes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,9 @@ main (void)
|
||||
/* And the data allocated in the .shstrtab section. */
|
||||
free (data->d_buf);
|
||||
|
||||
/* And the dynamic entries. */
|
||||
free (dyn);
|
||||
|
||||
/* All done. */
|
||||
if (elf_end (elf) != 0)
|
||||
{
|
||||
|
||||
@@ -184,6 +184,7 @@ main (int argc, char **argv)
|
||||
dwarf_encoding_string (state.info[i].type),
|
||||
state.info[i].bits);
|
||||
}
|
||||
free (state.info);
|
||||
}
|
||||
else
|
||||
do
|
||||
|
||||
@@ -70,6 +70,7 @@ main (int argc, char *argv[])
|
||||
offset += len + 1;
|
||||
}
|
||||
|
||||
dwarf_end (dbg);
|
||||
close (fd);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ handle_function (Dwarf_Die *funcdie, void *arg)
|
||||
|
||||
print_vars (indent + INDENT, die);
|
||||
}
|
||||
free (scopes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -42,5 +42,6 @@ main (int argc, char **argv)
|
||||
assert (die == &die_mem);
|
||||
assert (dwarf_tag (die) == 0);
|
||||
|
||||
dwarf_end (dw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -36,4 +36,7 @@ main (int argc, char **argv)
|
||||
Elf_Scn *scn = NULL;
|
||||
while ((scn = elf_nextscn (stripped, scn)) != NULL)
|
||||
elf_flagdata (elf_getdata (scn, NULL), ELF_C_SET, ELF_F_DIRTY);
|
||||
|
||||
elf_end (stripped);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user