#19 Fixed possible hard Crash when scanning files.

This commit is contained in:
gjefferyes
2015-09-16 20:09:54 -05:00
parent 5107b5b850
commit b6be1a9ec1

View File

@@ -26,11 +26,7 @@ namespace ROMVault2.SupportedFiles.Files
bSHA1 = null;
crc = null;
Stream ds;
int errorCode = IO.FileStream.OpenFileRead(filename, out ds);
if (errorCode != 0)
return errorCode;
Stream ds=null;
CRC32Hash crc32 = new CRC32Hash();
MD5 md5 = null;
@@ -38,6 +34,12 @@ namespace ROMVault2.SupportedFiles.Files
SHA1 sha1 = null;
if (testDeep) sha1 = SHA1.Create();
try
{
int errorCode = IO.FileStream.OpenFileRead(filename, out ds);
if (errorCode != 0)
return errorCode;
long sizetogo = ds.Length;
while (sizetogo > 0)
@@ -56,6 +58,15 @@ namespace ROMVault2.SupportedFiles.Files
if (testDeep) sha1.TransformFinalBlock(Buffer, 0, 0);
ds.Close();
}
catch
{
if (ds != null)
ds.Close();
return 0x17;
}
crc = crc32.Hash;
if (testDeep) bMD5 = md5.Hash;