libdwfl: Don't stack allocate alternate_name in dwfl_linux_kernel_find_elf.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
This commit is contained in:
Mark Wielaard
2015-05-19 12:58:49 +02:00
parent 251f1459aa
commit 08e5ae6fc8
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -1,3 +1,8 @@
2015-05-19 Mark Wielaard <mjw@redhat.com>
* linux-kernel-modules.c (dwfl_linux_kernel_find_elf): malloc and
free alternate_name.
2015-05-19 Mark Wielaard <mjw@redhat.com>
* linux-kernel-modules.c (dwfl_linux_kernel_report_offline): Don't
+8 -1
View File
@@ -707,7 +707,12 @@ dwfl_linux_kernel_find_elf (Dwfl_Module *mod,
two files when either a '_' or '-' appears in a module name, one using
only '_' and one only using '-'. */
char alternate_name[namelen + 1];
char *alternate_name = malloc (namelen + 1);
if (unlikely (alternate_name == NULL))
{
free (modulesdir[0]);
return ENOMEM;
}
inline bool subst_name (char from, char to)
{
const char *n = memchr (module_name, from, namelen);
@@ -757,6 +762,7 @@ dwfl_linux_kernel_find_elf (Dwfl_Module *mod,
*file_name = strdup (f->fts_path);
fts_close (fts);
free (modulesdir[0]);
free (alternate_name);
if (fd < 0)
free (*file_name);
else if (*file_name == NULL)
@@ -782,6 +788,7 @@ dwfl_linux_kernel_find_elf (Dwfl_Module *mod,
fts_close (fts);
free (modulesdir[0]);
free (alternate_name);
errno = error;
return -1;
}