summaryrefslogtreecommitdiff
path: root/libdwfl/find-debuginfo.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-06-06 23:40:42 +0200
committerMark Wielaard <mjw@redhat.com>2015-06-09 22:55:13 +0200
commit73b186aa6e9f3ddf2dd6963f55e678e8e954eb03 (patch)
tree0e6f572c3fec77112cb6eda81a6a91c3703e3716 /libdwfl/find-debuginfo.c
parent93d895970ddd4cd9c0392ab16bad94def1a8ff70 (diff)
downloadelfutils-73b186aa6e9f3ddf2dd6963f55e678e8e954eb03.tar.gz
libdwfl: Fix memory leak in find_debuginfo_in_path.
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>
Diffstat (limited to 'libdwfl/find-debuginfo.c')
-rw-r--r--libdwfl/find-debuginfo.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
index 9b911c1e..c5233548 100644
--- a/libdwfl/find-debuginfo.c
+++ b/libdwfl/find-debuginfo.c
@@ -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;
}