Use a using statement to make sure the file is closed when we return

This commit is contained in:
de4dot 2012-04-23 14:25:12 +02:00
parent 4f34e5c374
commit dba8d8ebef

View File

@ -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) {