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>
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;
}