Skip to contentSkip to conversation

Fix file descriptor leak on error in read_mroute_list()

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

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

PATCH 9/11 Fix file descriptor leak on error in read_mroute_list()

Detected by cppcheck.

---
 ip/ipmroute.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
ip/ipmroute.c +3 -1
index f033349..945727d 100644
@@ -85,8 +85,10 @@ static void read_mroute_list(FILE *ofp)
 	if (!fp)
 		return;
 
-	if (!fgets(buf, sizeof(buf), fp))
+	if (!fgets(buf, sizeof(buf), fp)) {
+		fclose(fp);
 		return;
+	}
 
 	while (fgets(buf, sizeof(buf), fp)) {
 		inet_prefix maddr, msrc;
Signature · 1 line
1.7.4.4