Skip to content

Commit

Permalink
fix nim-lang#19600 No error checking on fclose
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed May 27, 2022
1 parent d81edca commit 2abb57c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/std/syncio.nim
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ const
proc close*(f: File) {.tags: [], gcsafe.} =
## Closes the file.
if not f.isNil:
discard c_fclose(f)
let x = c_fclose(f)
if x < 0:
checkErr(f)

proc readChar*(f: File): char {.tags: [ReadIOEffect].} =
## Reads a single character from the stream `f`. Should not be used in
Expand Down
9 changes: 9 additions & 0 deletions tests/misc/t19600.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
discard """
targets: "c cpp"
disabled: "win"
disabled: "osx"
exitcode: 1
outputsub: "No space left on device"
"""

writeFile("/dev/full", "hello\n")

0 comments on commit 2abb57c

Please sign in to comment.