diff options
author | 2020-08-06 05:47:05 +1000 | |
---|---|---|
committer | 2020-08-06 05:47:05 +1000 | |
commit | 309a2ee063ecf5e1cbd3df8a1e4c17ae691b2668 (patch) | |
tree | 60e0935e0fc9f7ea071a0756f1ef6a75430eba8b /src/emu/debug/debugcmd.cpp | |
parent | a27476cec72abaec63252463b3805d732eb6d2e2 (diff) |
-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.
Diffstat (limited to 'src/emu/debug/debugcmd.cpp')
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 48 |
1 files changed, 23 insertions, 25 deletions
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<std::strin { u64 offset, length; memory_region *region; - FILE *f; /* validate parameters */ if (!validate_number_parameter(params[1], offset)) @@ -1987,21 +1986,21 @@ void debugger_commands::execute_saveregion(int ref, const std::vector<std::strin if (!validate_memory_region_parameter(params[3], region)) return; - /* open the file */ - f = fopen(params[0].c_str(), "wb"); - if (!f) { - m_console.printf("Error opening file '%s'\n", params[0].c_str()); + if (offset >= 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<std::string> &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<std::string> ¶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<std::strin if (!validate_memory_region_parameter(params[3], region)) return; + if (offset >= 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<std::strin u64 size = ftell(f); rewind(f); - if(offset >= 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); |