summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorVindaar <basti90@gmail.com>2018-10-20 20:35:04 +0200
committerVindaar <basti90@gmail.com>2018-10-20 20:35:04 +0200
commite190f485ae7aaa89c989570c97c199884b66dab6 (patch)
treef2f8650f14c3dd9dbd50a427c33299c0b39bedc0 /lib/system
parent863d3ef4ed7d18877a42f0060ebe63c34a27cf32 (diff)
downloadNim-e190f485ae7aaa89c989570c97c199884b66dab6.tar.gz
fixes #9456 by only calling `c_fclose` if non nil
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/sysio.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 61835e0f7..20964b166 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -130,7 +130,10 @@ else:
 const
   BufSize = 4000
 
-proc close*(f: File) = discard c_fclose(f)
+proc close*(f: File) =
+  if not f.isNil:
+    discard c_fclose(f)
+
 proc readChar(f: File): char =
   let x = c_fgetc(f)
   if x < 0:
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205