Skip to content

Commit 5d0d680

Browse files
committed
Improve CLI --entryslot
Accepted values are 0 to 999. Rewrite this part to use strtol and test for values in that range.
1 parent 3bfed62 commit 5d0d680

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

retroarch.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7486,13 +7486,16 @@ static bool retroarch_parse_input_and_config(
74867486
case 'e':
74877487
{
74887488
char *endptr;
7489-
int16_t entry_state_slot = (unsigned)strtoul(optarg, &endptr, 0);
7489+
long entry_state_slot = strtol(optarg, &endptr, 0);
74907490

7491-
if (entry_state_slot > -1 && string_is_empty(endptr))
7492-
runloop_st->entry_state_slot = entry_state_slot;
7493-
else
7491+
if (endptr == optarg || *endptr != '\0' ||
7492+
entry_state_slot < 0 || entry_state_slot > 999)
7493+
{
74947494
RARCH_WARN("[State]: --entryslot argument \"%s\" is not a valid "
74957495
"entry state slot index. Ignoring.\n", optarg);
7496+
}
7497+
else
7498+
runloop_st->entry_state_slot = entry_state_slot;
74967499
}
74977500
break;
74987501
case RA_OPT_DATABASE_SCAN:

0 commit comments

Comments
 (0)