diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-05-27 13:04:16 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-05-27 13:04:16 -0400 |
| commit | e6ef806ef40a421435b1209f0f79d778c03fe04a (patch) | |
| tree | 4a099e9cfe1084f24b990c833a97285c2b442990 /src/stdio/fclose.c | |
| parent | 7d71ad2b8589bef1bdf26c3cfec5ab99b6bba3b9 (diff) | |
handle use-after-close
Diffstat (limited to 'src/stdio/fclose.c')
| -rw-r--r-- | src/stdio/fclose.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c index f438a9c2..37198fcb 100644 --- a/src/stdio/fclose.c +++ b/src/stdio/fclose.c @@ -26,7 +26,7 @@ int fclose(FILE *stream) SIGNAL_SAFE(0); flockfile(stream); - if (fflush(stream) == EOF) { + if (stream->operation == OP_OUTPUT && fflush(stream) == EOF) { /* set errno */ return EOF; } @@ -44,6 +44,7 @@ int fclose(FILE *stream) } memset(stream, '\0', sizeof(*stream)); + stream->fd = -1; /* RETURN_SUCCESS(0); |
