From 8d899d019a45ce27bdb21d4d58cf89e7fd4aa22f Mon Sep 17 00:00:00 2001 From: arookas Date: Sat, 12 Dec 2015 16:52:34 -0500 Subject: [PATCH] Fixed: dispose file even if an error occurs. --- context.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/context.cs b/context.cs index 8830c40..18beef3 100644 --- a/context.cs +++ b/context.cs @@ -88,12 +88,18 @@ namespace arookas var result = ImportResolver.ResolveImport(name, out file); if (result == sunImportResult.Loaded) { - ImportResolver.EnterFile(file); - var parser = new sunParser(); - var tree = parser.Parse(file); - tree.Compile(this); - ImportResolver.ExitFile(file); - file.Dispose(); + try + { + ImportResolver.EnterFile(file); + var parser = new sunParser(); + var tree = parser.Parse(file); + tree.Compile(this); + ImportResolver.ExitFile(file); + } + finally + { + file.Dispose(); + } } return result; }