summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fclose.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-10-24 13:50:36 +0200
committerAnton Kling <anton@kling.gg>2023-10-24 13:50:36 +0200
commit3ae251a204748a2f1c4c2af6c55e73d5e5159d0f (patch)
tree07d02eb1b25173e3af41284a9def4cdb9191bb97 /userland/libc/stdio/fclose.c
parente91a4f1e31ee100b2a13cefedb182e9d69ef04ad (diff)
LibC: Allocate stdin, stdout, stderr on the heap so they can be closed with fclose
Diffstat (limited to 'userland/libc/stdio/fclose.c')
-rw-r--r--userland/libc/stdio/fclose.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/userland/libc/stdio/fclose.c b/userland/libc/stdio/fclose.c
index 02d93ae..01bdb22 100644
--- a/userland/libc/stdio/fclose.c
+++ b/userland/libc/stdio/fclose.c
@@ -4,7 +4,8 @@
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html
// FIXME: Do some actual error checking.
int fclose(FILE *stream) {
+ if (stream)
free(stream->cookie);
- free(stream);
- return 0;
+ free(stream);
+ return 0;
}