summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorChristopher Dunn <cdunn2001@gmail.com>2017-05-15 09:52:57 -0500
committerChristopher Dunn <cdunn2001@gmail.com>2017-05-15 09:52:57 -0500
commit117c983d13d4e6ff76c09d988cd5114294852ff0 (patch)
treed4aeef7380d4f9fbcec6ecf0809d319379cf5813 /lib
parent6bbf0fb64d4037b1ae7f00af0c153b1064e05355 (diff)
downloadNim-117c983d13d4e6ff76c09d988cd5114294852ff0.tar.gz
Use writeable file in parsecfg.writeConfig()
Fixes #5816
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/parsecfg.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim
index 28681a11f..307808556 100644
--- a/lib/pure/parsecfg.nim
+++ b/lib/pure/parsecfg.nim
@@ -540,7 +540,8 @@ proc writeConfig*(dict: Config, filename: string) =
   ## Writes the contents of the table to the specified configuration file.
   ## Note: Comment statement will be ignored.
   let file = open(filename, fmWrite)
-  let fileStream = newFileStream(filename)
+  defer: file.close()
+  let fileStream = newFileStream(file)
   defer: fileStream.close()
   dict.writeConfig(fileStream)