From f0bc0bdd2c7ce28df00f4d74fa28a7835b61eb27 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 13 Feb 2004 10:56:43 +0000 Subject: A better fix... --- utils/ldd.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/ldd.c b/utils/ldd.c index 96cffffeb..e6a331dad 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -281,7 +281,7 @@ void locate_library_file(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, int is_suid, stru /* If this is a fully resolved name, our job is easy */ if (stat (lib->name, &filestat) == 0) { - lib->path = lib->name; + lib->path = strdup(lib->name); return; } @@ -470,7 +470,7 @@ static struct library * find_elf_interpreter(Elf32_Ehdr* ehdr) return NULL; newlib->name = malloc(strlen(s)+1); strcpy(newlib->name, s); - newlib->path = newlib->name; + newlib->path = strdup(newlib->name); newlib->resolved = 1; newlib->next = NULL; @@ -664,14 +664,12 @@ int main( int argc, char** argv) printf("\tnot a dynamic executable\n"); for (cur = lib_list; cur; cur=cur->next) { + free(cur->name); + cur->name=NULL; if (cur->path && cur->path != not_found) { free(cur->path); cur->path=NULL; } - if (cur->name) { - free(cur->name); - cur->name=NULL; - } } lib_list=NULL; } -- cgit v1.2.3