From 4dbffd990276fc6b9a3ffcca4a3c6686cc60ef4c Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 29 May 2024 16:58:53 -0400 Subject: only attempt to flush streams that can be flushed when parameter is NULL --- src/stdio/fflush.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 2250aaaf..a1e984f9 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -13,7 +13,10 @@ int fflush(FILE *stream) if (stream == NULL) { size_t i; for (i = 0; i < FOPEN_MAX; i++) { - fflush(&(__stdio.FILES[i])); + stream = __stdio.FILES + i; + if (stream->write && (stream->operation != OP_INPUT)) { + fflush(stream); + } } return 0; } -- cgit v1.2.1