Selaa lähdekoodia

Avoid potential double free when locate_library_file() is used
on fully resolved names

Eric Andersen 21 vuotta sitten
vanhempi
commit
6eec2e331f
1 muutettua tiedostoa jossa 7 lisäystä ja 4 poistoa
  1. 7 4
      utils/ldd.c

+ 7 - 4
utils/ldd.c

@@ -669,11 +669,14 @@ 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)
+			if (cur->path && cur->path != not_found) {
 				free(cur->path);
-			cur->path=NULL;
+				cur->path=NULL;
+			}
+			if (cur->name) {
+				free(cur->name);
+				cur->name=NULL;
+			}
 		}
 		lib_list=NULL;
 	}