From a9d1ad16b1e19a0cb1ad2b2bc1048d5cf2ccb08e Mon Sep 17 00:00:00 2001 From: nattthebear Date: Sat, 20 Jun 2020 19:21:55 -0400 Subject: [PATCH] GPGX: Saveram tweaks When saveram doesn't exist, return null, not new byte [0]. If passed a 0-length saveram file, do not pass it to the core (this crashed in interop stubs). Note that as best as I can tell, this is not fixing any problem; even without this commit it seems impossible to get BizHawk to actually generate a 0 byte saveram file for GPGX because of other checks that already existed. --- .../Consoles/Sega/gpgx64/GPGX.ISaveRam.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs index 55bab54129..2a28bed9c3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx int size = 0; IntPtr area = Core.gpgx_get_sram(ref size); if (size == 0 || area == IntPtr.Zero) - return new byte[0]; + return null; byte[] ret = new byte[size]; using (_elf.EnterExit()) @@ -22,6 +22,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public void StoreSaveRam(byte[] data) { + if (data.Length == 0) + { + // not sure how this is happening, but reject them + return; + } if (!Core.gpgx_put_sram(data, data.Length)) { throw new Exception("Core rejected saveram");