From: Thomas Jarosch Date: Mon, 3 Oct 2011 05:22:42 +0000 (+0000) Subject: Fix file descriptor leak on error in rtnl_hash_initialize() X-Git-Tag: v3.0.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97c13582f98377c9e1a72ed40fb2b80225c4c0f9;p=thirdparty%2Fiproute2.git Fix file descriptor leak on error in rtnl_hash_initialize() Detected by cppcheck. Signed-off-by: Thomas Jarosch --- diff --git a/lib/rt_names.c b/lib/rt_names.c index 30d43cd00..a290021b9 100644 --- a/lib/rt_names.c +++ b/lib/rt_names.c @@ -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; }