]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix leak in debuginfo.c
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 12 Mar 2012 22:06:57 +0000 (22:06 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 12 Mar 2012 22:06:57 +0000 (22:06 +0000)
di->soname was not freed, so was leaked when debug info is removed.
free(soname) added in free_Debuginfo, after having verified
and then ensured that all soname are allocated in dinfo.

regtested on deb6/amd64

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12442

coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/priv_storage.h
coregrind/m_debuginfo/readelf.c

index 7bd431172bcd160d2b0eadfaf3a31176a2c666bd..fa08d8ed639a6eded6bf10d447dd48a6fd6c71b6 100644 (file)
@@ -205,6 +205,7 @@ static void free_DebugInfo ( DebugInfo* di )
 
    vg_assert(di != NULL);
    if (di->fsm.filename) ML_(dinfo_free)(di->fsm.filename);
+   if (di->soname)       ML_(dinfo_free)(di->soname);
    if (di->loctab)       ML_(dinfo_free)(di->loctab);
    if (di->cfsi)         ML_(dinfo_free)(di->cfsi);
    if (di->cfsi_exprs)   VG_(deleteXA)(di->cfsi_exprs);
index 99f0ad4cada5b1339ae8f850de1dc96ea54184fe..53ca0d2c125a19293736e765966ef4c313e1dbed 100644 (file)
@@ -515,8 +515,7 @@ struct _DebugInfo {
       we have committed to reading the symbols and debug info (that
       is, at the point where .have_dinfo is set to True). */
 
-   /* The file's soname.  FIXME: ensure this is always allocated in
-      VG_AR_DINFO. */
+   /* The file's soname. */
    UChar* soname;
 
    /* Description of some important mapped segments.  The presence or
index 7e2e771a598aa529c771d25ee62d171116730f15..471447191b26c88e4ee26d7786814deac757e0c0 100644 (file)
@@ -1605,7 +1605,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
       find a soname, add a fake one. */
    if (di->soname == NULL) {
       TRACE_SYMTAB("No soname found; using (fake) \"NONE\"\n");
-      di->soname = "NONE";
+      di->soname = ML_(dinfo_strdup)("di.redi.2", "NONE");
    }
 
    vg_assert(n_rx >= 0 && n_rx <= N_RX_RW_AREAS);