]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
fpurge: Make it work with non fd based FILEs
authorDuncan Overbruck <mail@duncano.de>
Tue, 25 Jan 2022 19:32:30 +0000 (20:32 +0100)
committerGuillem Jover <guillem@hadrons.org>
Wed, 26 Jan 2022 03:42:09 +0000 (04:42 +0100)
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>
src/fpurge.c

index 462535ab506d6f72785986ee053e8606421c0ecc..350f364c0fc8e4ca214f8431753f60434ba06954 100644 (file)
@@ -32,7 +32,7 @@
 int
 fpurge(FILE *fp)
 {
-       if (fp == NULL || fileno(fp) < 0) {
+       if (fp == NULL) {
                errno = EBADF;
                return EOF;
        }