Merge pull request #6437 from quasiscroto/debugfix

Fix two cases where debugger can crash mame ("cheatlist" command befo…
This commit is contained in:
R. Belmont 2020-03-13 17:26:22 -04:00 committed by GitHub
commit 9d428b4dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -2535,6 +2535,12 @@ void debugger_commands::execute_cheatlist(int ref, const std::vector<std::string
u64 sizemask;
FILE *f = nullptr;
if (m_cheat.cpu[0] == 0)
{
m_console.printf("Use cheatinit before cheatlist\n");
return;
}
if (!validate_cpu_space_parameter(m_cheat.cpu, AS_PROGRAM, space))
return;

View File

@ -1561,16 +1561,11 @@ const char *debug_get_help(const char *tag)
static char ambig_message[1024];
const help_item *found = nullptr;
int i, msglen, foundcount = 0;
int taglen = (int)strlen(tag);
char tagcopy[256];
/* make a lowercase copy of the tag */
for (i = 0; i <= taglen; i++)
tagcopy[i] = tolower(u8(tag[i]));
size_t taglen = strlen(tag);
/* find a match */
for (i = 0; i < ARRAY_LENGTH(static_help_list); i++)
if (!strncmp(static_help_list[i].tag, tagcopy, taglen))
if (!core_strnicmp(static_help_list[i].tag, tag, taglen))
{
foundcount++;
found = &static_help_list[i];
@ -1592,7 +1587,7 @@ const char *debug_get_help(const char *tag)
/* otherwise, indicate ambiguous help */
msglen = sprintf(ambig_message, "Ambiguous help request, did you mean:\n");
for (i = 0; i < ARRAY_LENGTH(static_help_list); i++)
if (!strncmp(static_help_list[i].tag, tagcopy, taglen))
if (!core_strnicmp(static_help_list[i].tag, tag, taglen))
msglen += sprintf(&ambig_message[msglen], " help %s?\n", static_help_list[i].tag);
return ambig_message;
}