From dba8d8ebefc6ee189447250e60677d0e4364b493 Mon Sep 17 00:00:00 2001 From: de4dot Date: Mon, 23 Apr 2012 14:25:12 +0200 Subject: [PATCH] Use a using statement to make sure the file is closed when we return --- de4dot.code/deobfuscators/CliSecure/CliSecureRtType.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/de4dot.code/deobfuscators/CliSecure/CliSecureRtType.cs b/de4dot.code/deobfuscators/CliSecure/CliSecureRtType.cs index 25dab69d..0bc64274 100644 --- a/de4dot.code/deobfuscators/CliSecure/CliSecureRtType.cs +++ b/de4dot.code/deobfuscators/CliSecure/CliSecureRtType.cs @@ -152,9 +152,10 @@ namespace de4dot.code.deobfuscators.CliSecure { if ((module.Attributes & ModuleAttributes.ILOnly) != 0) return false; - var peImage = new PeImage(new FileStream(module.FullyQualifiedName, FileMode.Open, FileAccess.Read, FileShare.Read)); - foundSig = MethodsDecrypter.detect(peImage); - return foundSig; + using (var file = new FileStream(module.FullyQualifiedName, FileMode.Open, FileAccess.Read, FileShare.Read)) { + var peImage = new PeImage(file); + return foundSig = MethodsDecrypter.detect(peImage); + } } static bool hasPinvokeMethod(TypeDefinition type, string methodName) {