From 309a2ee063ecf5e1cbd3df8a1e4c17ae691b2668 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 6 Aug 2020 05:47:05 +1000 Subject: -debug/debugcmd.cpp: Don't leak an open FILE when an argument is invalid and also fixed a spelling error. * The saver/loadr commands should consider region endianness for portability. -cpu/gigatron: Capitalisation of hex values was inconsistent, change it to lowercase as that tends to be the MAME standard. -machine/exorterm.cpp: Fixed inputs magically changing on reset when they shouldn't (there are still others that should be fixed). -mpu4vid.cpp: Corrected some errors in game descriptions. -Fixed a couple of editing errors. --- src/emu/debug/debugcmd.cpp | 48 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'src/emu/debug/debugcmd.cpp') diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 20263e435c7..309c73ecf22 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -1977,7 +1977,6 @@ void debugger_commands::execute_saveregion(int ref, const std::vector= region->bytes()) + { + m_console.printf("Invalid offset\n"); return; } + if ((length <= 0) || ((length + offset) >= region->bytes())) + length = region->bytes() - offset; - if(offset >= region->bytes()) { - m_console.printf("Invalide offset\n"); + /* open the file */ + FILE *f = fopen(params[0].c_str(), "wb"); + if (!f) + { + m_console.printf("Error opening file '%s'\n", params[0].c_str()); return; } - // get full length - if(length <= 0 || length + offset >= region->bytes()) { - length = region->bytes() - offset; - } fwrite(region->base() + offset, 1, length, f); fclose(f); @@ -2118,14 +2117,13 @@ void debugger_commands::execute_load(int ref, const std::vector &pa /*------------------------------------------------- - execute_saveregion - execute the save command on region memory + execute_loadregion - execute the load command on region memory -------------------------------------------------*/ void debugger_commands::execute_loadregion(int ref, const std::vector ¶ms) { u64 offset, length; memory_region *region; - FILE *f; /* validate parameters */ if (!validate_number_parameter(params[1], offset)) @@ -2135,9 +2133,18 @@ void debugger_commands::execute_loadregion(int ref, const std::vector= region->bytes()) + { + m_console.printf("Invalid offset\n"); + return; + } + if ((length <= 0) || ((length + offset) >= region->bytes())) + length = region->bytes() - offset; + /* open the file */ - f = fopen(params[0].c_str(), "rb"); - if (!f) { + FILE *f = fopen(params[0].c_str(), "rb"); + if (!f) + { m_console.printf("Error opening file '%s'\n", params[0].c_str()); return; } @@ -2146,18 +2153,9 @@ void debugger_commands::execute_loadregion(int ref, const std::vector= region->bytes()) { - m_console.printf("Invalide offset\n"); - return; - } - // get full length - if(length <= 0 || length + offset >= region->bytes()) { - length = region->bytes() - offset; - } // check file size - if(length >= size) { + if (length >= size) length = size; - } fread(region->base() + offset, 1, length, f); -- cgit v1.2.3