Skip to contentSkip to conversation

Fix file descriptor leak on error in rtnl_hash_initialize()

PATCH In review Thomas Jarosch 1 participant 1 message Oct 3, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/11 Fix file descriptor leak on error in rtnl_hash_initialize()

Detected by cppcheck.

---
 lib/rt_names.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
lib/rt_names.c +2 -0
index 30d43cd..a290021 100644
@@ -54,6 +54,7 @@ rtnl_hash_initialize(char *file, struct rtnl_hash_entry **hash, int size)
 		    sscanf(p, "%d %s #", &id, namebuf) != 2) {
 			fprintf(stderr, "Database %s is corrupted at %s\n",
 				file, p);
+			fclose(fp);
 			return;
 		}
 
@@ -91,6 +92,7 @@ static void rtnl_tab_initialize(char *file, char **tab, int size)
 		    sscanf(p, "%d %s #", &id, namebuf) != 2) {
 			fprintf(stderr, "Database %s is corrupted at %s\n",
 				file, p);
+			fclose(fp);
 			return;
 		}
 
Signature · 1 line
1.7.4.4