util: eliminate some out of memory problems with hashing large files

gpgx: warn and abort when a too-big file tries to be loaded as a ROM (probably was actually a .bin cd image without the correct .cue)
This commit is contained in:
goyuken 2014-03-05 18:16:34 +00:00
parent 60147ffbab
commit 4e70f1d6a5
2 changed files with 6 additions and 2 deletions

View File

@ -22,7 +22,7 @@ namespace BizHawk.Common
{ {
using (var md5 = System.Security.Cryptography.MD5.Create()) using (var md5 = System.Security.Cryptography.MD5.Create())
{ {
md5.TransformFinalBlock(data, offset, len); md5.ComputeHash(data, offset, len);
return BytesToHexString(md5.Hash); return BytesToHexString(md5.Hash);
} }
} }
@ -36,7 +36,7 @@ namespace BizHawk.Common
{ {
using (var sha1 = System.Security.Cryptography.SHA1.Create()) using (var sha1 = System.Security.Cryptography.SHA1.Create())
{ {
sha1.TransformFinalBlock(data, offset, len); sha1.ComputeHash(data, offset, len);
return BytesToHexString(sha1.Hash); return BytesToHexString(sha1.Hash);
} }
} }

View File

@ -49,6 +49,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
//hack, don't use //hack, don't use
//romfile = File.ReadAllBytes(@"D:\encodes\bizhawksrc\output\SANIC CD\PierSolar (E).bin"); //romfile = File.ReadAllBytes(@"D:\encodes\bizhawksrc\output\SANIC CD\PierSolar (E).bin");
if (romfile != null && romfile.Length > 16 * 1024 * 1024)
{
throw new InvalidOperationException("ROM too big! Did you try to load a CD as a ROM?");
}
try try
{ {