From 3ae251a204748a2f1c4c2af6c55e73d5e5159d0f Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Tue, 24 Oct 2023 13:50:36 +0200 Subject: LibC: Allocate stdin, stdout, stderr on the heap so they can be closed with fclose --- userland/libc/stdio/fclose.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'userland/libc/stdio/fclose.c') 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; } -- cgit v1.2.3