summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-02-13 10:56:43 +0000
committerEric Andersen <andersen@codepoet.org>2004-02-13 10:56:43 +0000
commitf0bc0bdd2c7ce28df00f4d74fa28a7835b61eb27 (patch)
tree118addfd3f168807f441339bd2f65f5d7747623a /utils
parentb1cd8389a20d6a45b92bc82f92a046008d334ce5 (diff)
A better fix...
Diffstat (limited to 'utils')
-rw-r--r--utils/ldd.c10
1 files changed, 4 insertions, 6 deletions
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;
}