From c56cd675f241ae1ff1451deb0c974341e9dd7322 Mon Sep 17 00:00:00 2001 From: smf- Date: Tue, 20 Sep 2016 13:28:39 +0100 Subject: [PATCH] Fixed trace command access a parameter beyond the list supplied, added an error message if you provide an invalid boolean, allow boolean to be case-insensitive and skip empty strings when parsing booleans. [smf] --- src/emu/debug/debugcmd.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index cba9368dbf4..99cdefb3b36 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -387,15 +387,18 @@ bool debugger_commands::validate_number_parameter(const char *param, UINT64 *res bool debugger_commands::validate_boolean_parameter(const char *param, bool *result) { /* nullptr parameter does nothing and returns no error */ - if (param == nullptr) + if (param == nullptr || strlen(param) == 0) return true; /* evaluate the expression; success if no error */ - bool is_true = (strcmp(param, "true") == 0 || strcmp(param, "TRUE") == 0 || strcmp(param, "1") == 0); - bool is_false = (strcmp(param, "false") == 0 || strcmp(param, "FALSE") == 0 || strcmp(param, "0") == 0); + bool is_true = (core_stricmp(param, "true") == 0 || strcmp(param, "1") == 0); + bool is_false = (core_stricmp(param, "false") == 0 || strcmp(param, "0") == 0); if (!is_true && !is_false) + { + m_console.printf("Invalid boolean '%s'\n", param); return false; + } *result = is_true; @@ -2482,7 +2485,7 @@ void debugger_commands::execute_trace_internal(int ref, int params, const char * return; if (!validate_boolean_parameter((params > 2) ? param[2] : nullptr, &detect_loops)) return; - if (!debug_command_parameter_command(action = param[3])) + if (!debug_command_parameter_command(action = (params > 3) ? param[3] : nullptr)) return; /* open the file */