summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authorPavel Roschin <roshin@scriptumplus.ru>2016-02-02 23:20:39 +0300
committerPavel Roschin <roshin@scriptumplus.ru>2016-02-02 23:20:39 +0300
commit17dff030ae4eab34c06117aef97aac0c3ad9342a (patch)
treed7620acb99ed6416b8f07e227d1214f6e735951a /lib/system.nim
parent3e33084da7ed51818335ba785c2de837a4d653db (diff)
downloadNim-17dff030ae4eab34c06117aef97aac0c3ad9342a.tar.gz
Use defer in iterator to avoid possible leaks. Fixes #3802
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 69c6e1290..1a0a11ff0 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2960,9 +2960,9 @@ when not defined(JS): #and not defined(nimscript):
       ##       buffer.add(line.replace("a", "0") & '\x0A')
       ##     writeFile(filename, buffer)
       var f = open(filename, bufSize=8000)
+      defer: close(f)
       var res = TaintedString(newStringOfCap(80))
       while f.readLine(res): yield res
-      close(f)
 
     iterator lines*(f: File): TaintedString {.tags: [ReadIOEffect].} =
       ## Iterate over any line in the file `f`.
changelog.md?h=devel&id=c17f6c7837d9fc2268543e34c03f95e50229650d'>^
d52a1061b ^

b14cc1e3b ^


d52a1061b ^

d7a896f19 ^


90c1b94fb ^

560d87f5f ^
90c1b94fb ^
9565da11e ^
089506498 ^

4e4d466d0 ^







742f43e57 ^












136dbd3c6 ^










5e66a7ce5 ^



a4d40d137 ^


661ce8b8c ^

908a25a2c ^

55cdaaef6 ^
844e12306 ^

0594a3a70 ^


908a25a2c ^
0594a3a70 ^






8d1a5dc8e ^



5d2e86ea1 ^






b74a5148a ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110