Skip to contentSkip to conversation

Fix file descriptor leak on error in read_viftable()

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

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

PATCH 8/11 Fix file descriptor leak on error in read_viftable()

Detected by cppcheck.

---
 ip/ipmroute.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
ip/ipmroute.c +3 -2
index a4389f5..f033349 100644
@@ -58,9 +58,10 @@ static void read_viftable(void)
 	if (!fp)
 		return;
 
-	if (!fgets(buf, sizeof(buf), fp))
+	if (!fgets(buf, sizeof(buf), fp)) {
+		fclose(fp);
 		return;
-
+	}
 	while (fgets(buf, sizeof(buf), fp)) {
 		int vifi;
 		char dev[256];
Signature · 1 line
1.7.4.4