From 36d09de3201243daca56f122c3740415508f105f Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Wed, 6 Apr 2016 15:21:55 +0300 Subject: [PATCH] Fixed FD leak. --- src/nimblepkg/packageparser.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nimblepkg/packageparser.nim b/src/nimblepkg/packageparser.nim index 3eb1907..cf641a9 100644 --- a/src/nimblepkg/packageparser.nim +++ b/src/nimblepkg/packageparser.nim @@ -118,6 +118,7 @@ proc readPackageInfoFromNimble(path: string; result: var PackageInfo) = if fs != nil: var p: CfgParser open(p, fs, path) + defer: close(p) var currentSection = "" while true: var ev = next(p) @@ -172,7 +173,6 @@ proc readPackageInfoFromNimble(path: string; result: var PackageInfo) = "Invalid package info, should not contain --" & ev.value) of cfgError: raise newException(NimbleError, "Error parsing .nimble file: " & ev.msg) - close(p) else: raise newException(ValueError, "Cannot open package info: " & path) @@ -269,4 +269,4 @@ proc getInstalledPkgs*(libsDir: string, options: Options): raise exc proc isNimScript*(nf: string, options: Options): bool = - result = readPackageInfo(nf, options).isNimScript \ No newline at end of file + result = readPackageInfo(nf, options).isNimScript