Commit ba3c46b30fd45c8d2df310d89fd560c55a74eb4a

Duncan Overbruck 2022-01-25T20:32:30

fpurge: Make it work with non fd based FILEs Streams opened with for example open_memstream(3) will have no associated file descriptor, and fileno(3) will fail. Signed-off-by: Guillem Jover <guillem@hadrons.org>

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/fpurge.c b/src/fpurge.c
index 462535a..350f364 100644
--- a/src/fpurge.c
+++ b/src/fpurge.c
@@ -32,7 +32,7 @@
 int
 fpurge(FILE *fp)
 {
-	if (fp == NULL || fileno(fp) < 0) {
+	if (fp == NULL) {
 		errno = EBADF;
 		return EOF;
 	}