OSDN Git Service

Done free path if it equals not_found
authorEric Andersen <andersen@codepoet.org>
Fri, 13 Feb 2004 11:05:36 +0000 (11:05 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 13 Feb 2004 11:05:36 +0000 (11:05 -0000)
Remember to flose an fopened file

utils/ldd.c

index 5accdc7..08e6683 100644 (file)
@@ -460,7 +460,8 @@ static struct library * find_elf_interpreter(Elf32_Ehdr* ehdr)
                                //printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name);
                                newlib = cur;
                                free(newlib->name);
-                               free(newlib->path);
+                               if (newlib->path != not_found) {
+                                       free(newlib->path);
                                newlib->name = NULL;
                                newlib->path = NULL;
                                return NULL;
@@ -515,6 +516,7 @@ int find_dependancies(char* filename)
        }
        if (fstat(fileno(thefile), &statbuf) < 0) {
                perror(filename);
+               flose(thefile);
                return -1;
        }
 
@@ -529,6 +531,8 @@ int find_dependancies(char* filename)
                        PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
 
 foo:
+       flose(thefile);
+
        /* Check if this looks like a legit ELF file */
        if (check_elf_header(ehdr)) {
                fprintf(stderr, "%s: not an ELF file.\n", filename);