From: Duncan Overbruck Date: Tue, 25 Jan 2022 19:32:30 +0000 (+0100) Subject: fpurge: Make it work with non fd based FILEs X-Git-Tag: 0.11.6~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba3c46b30fd45c8d2df310d89fd560c55a74eb4a;p=thirdparty%2Flibbsd.git 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 --- 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; }