From 7bd4a2f4aaabca0e46015fe0216c086c7f61f1d4 Mon Sep 17 00:00:00 2001
From: Eric Andersen <andersen@codepoet.org>
Date: Fri, 13 Feb 2004 11:11:10 +0000
Subject: Yet more fixups..

---
 utils/ldd.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/utils/ldd.c b/utils/ldd.c
index 08e66831f..537316452 100644
--- a/utils/ldd.c
+++ b/utils/ldd.c
@@ -462,6 +462,7 @@ static struct library * find_elf_interpreter(Elf32_Ehdr* ehdr)
 				free(newlib->name);
 				if (newlib->path != not_found) {
 					free(newlib->path);
+				}
 				newlib->name = NULL;
 				newlib->path = NULL;
 				return NULL;
@@ -516,7 +517,7 @@ int find_dependancies(char* filename)
 	}
 	if (fstat(fileno(thefile), &statbuf) < 0) {
 		perror(filename);
-		flose(thefile);
+		fclose(thefile);
 		return -1;
 	}
 
@@ -529,9 +530,14 @@ int find_dependancies(char* filename)
 	/* mmap the file to make reading stuff from it effortless */
 	ehdr = (Elf32_Ehdr *)mmap(0, statbuf.st_size,
 			PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
+	if (ehdr == MAP_FAILED) {
+		fclose(thefile);
+		fprintf(stderr, "Out of memory!\n");
+		return -1;
+	}
 
 foo:
-	flose(thefile);
+	fclose(thefile);
 
 	/* Check if this looks like a legit ELF file */
 	if (check_elf_header(ehdr)) {
-- 
cgit v1.2.3