1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-27 15:43:17 +00:00

Merge pull request #418 from ahungry/bugfix/Fix-double-free-fclose

Fix for double free on fclose due to GC not knowing it failed
This commit is contained in:
Calvin Rose 2020-05-28 17:24:09 -04:00 committed by GitHub
commit 4056b94e01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,7 +279,10 @@ static Janet cfun_io_fclose(int32_t argc, Janet *argv) {
return janet_wrap_integer(WEXITSTATUS(status));
#endif
} else {
if (fclose(iof->file)) janet_panic("could not close file");
if (fclose(iof->file)) {
iof->flags |= JANET_FILE_NOT_CLOSEABLE;
janet_panic("could not close file");
}
iof->flags |= JANET_FILE_CLOSED;
return janet_wrap_nil();
}