Commit 8cbe58099b1488354d3efbfcb9f4877ed5b1364c

Stefan Sperling 2019-05-21T11:08:12

plug /dev/null file descriptor leaks in diffreg.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/lib/diffreg.c b/lib/diffreg.c
index e48ec98..0823deb 100644
--- a/lib/diffreg.c
+++ b/lib/diffreg.c
@@ -419,7 +419,14 @@ closem:
 		if (*rval == D_SAME)
 			*rval = D_DIFFER;
 	}
-
+	if ((flags & D_EMPTY1) && f1) {
+		if (fclose(f1) != 0 && err == NULL)
+			err = got_error_from_errno("fclose");
+	}
+	if ((flags & D_EMPTY2) && f2) {
+		if (fclose(f2) != 0 && err == NULL)
+			err = got_error_from_errno("fclose");
+	}
 	return (err);
 }