]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Fix memory leak in find_debuginfo_in_path.
authorMark Wielaard <mjw@redhat.com>
Sat, 6 Jun 2015 21:40:42 +0000 (23:40 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 9 Jun 2015 20:55:13 +0000 (22:55 +0200)
commit c4f133 libdwfl: find_debuginfo_in_patch don't alloca/strdupa
strings of unknown size. Introduced a memory leak in the case nothing
was found. Make sure before returning all temporary strings are all
freed.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/find-debuginfo.c

index 956ac9ffeb3ccbc29ba5c289270402c5e2227e08..a5253e26155483e3052af9b7f9475533893fb426 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-06  Mark Wielaard  <mjw@redhat.com>
+
+       * find-debuginfo.c (find_debuginfo_in_path): Always free localpath,
+       localname and file_dirname.
+
 2015-06-06  Mark Wielaard  <mjw@redhat.com>
 
        * derelocate.c (cache_sections): Free sortrefs.
index 9b911c1e7718e37e50ee08dbdb750b57a5f7cff1..c5233548014b5ea8f19df8b6d53fa087b03043bc 100644 (file)
@@ -293,19 +293,13 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name,
              }
            continue;
          default:
-           {
-           fail_free:
-             free (localpath);
-             free (localname);
-             free (file_dirname);
-             return -1;
-           }
+           goto fail_free;
          }
-      free (localpath);
-      free (localname);
-      free (file_dirname);
       if (validate (mod, fd, check, debuglink_crc))
        {
+         free (localpath);
+         free (localname);
+         free (file_dirname);
          *debuginfo_file_name = fname;
          return fd;
        }
@@ -315,6 +309,10 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name,
 
   /* No dice.  */
   errno = 0;
+fail_free:
+  free (localpath);
+  free (localname);
+  free (file_dirname);
   return -1;
 }