From 5986d779e7beebe096545e7e85bb0c3d608e9133 Mon Sep 17 00:00:00 2001 From: goyuken Date: Fri, 14 Dec 2012 16:59:23 +0000 Subject: [PATCH] SMS: increase size of buffer for public byte[] SaveStateBinary() by 1 byte. also throw an exception if the savestate is smaller than expected. --- BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs index 8399199deb..841f61657b 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs @@ -305,10 +305,12 @@ namespace BizHawk.Emulation.Consoles.Sega public byte[] SaveStateBinary() { - var buf = new byte[24802 + 16384 + 16384]; + var buf = new byte[24802 + 1 + 16384 + 16384]; var stream = new MemoryStream(buf); var writer = new BinaryWriter(stream); SaveStateBinary(writer); + if (stream.Length != buf.Length) + throw new Exception(string.Format("savestate buffer underrun: {0} < {1}", stream.Length, buf.Length)); writer.Close(); return buf; }