Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't free-up file-descriptor of stdin/stdout/stderr
stdout, stdin and stderr are statically allocated at tinystdio/posixiob_stdout.c, tinystdio/posixiob_stdin.c and tinystdio/posixiob_stderr.c respectively. and the issue here is that the current implementation of `fclose()` frees the allocated memory for the stream file. When we call `fclose(stdout)` it tries to free an unallocated memory for _stdout_, so it frees a wrong pointer and saves it as a free heap space, then when trying to use this memory it causes memory corruption. So, we shouldn't free the memory if the stream is stdin, stdout or stderr.
- Loading branch information