-
-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
Description
https://en.cppreference.com/w/c/io/fclose.html
fclose returns 0 on success and EOF otherwise.
The default implementation of fclose wraps ti_Close, which returns 0 on error. Therefore the wrong value will be returned here:
int __attribute__((weak)) fclose(FILE *stream) {
ti_var_t slot;
if (stream == NULL ||
stream == stdin ||
stream == stdout ||
stream == stderr)
{
return EOF;
}
slot = stream->slot;
_file_streams[slot - 1].slot = 0;
return ti_Close(slot); // supposed to return 0 on success here
}