core options, runahead: check three small allocations

core_option_manager_parse_variable and _parse_option wrote each value's
hash through an unchecked malloc; a failure now fails that option, as
the functions' other failures do. runahead_input_state_set_last read
input_state_list->size after mylist_create could leave it NULL; it now
returns. Not reproduced: needs a failing allocator.

Closes #19838
This commit is contained in:
Anthony Schemel authored and libretroadmin committed 2026-10-15 22:55:31 +02:00
1 parent 81a5ff5f1e
commit c88fc9b66e
2 files changed
+8

No files matched your search

+6
View File
@@ -724,6 +724,9 @@ static bool core_option_manager_parse_variable(
const char *value_label = core_option_manager_parse_value_label(
value, NULL);
if (!value_hash)
goto error;
/* Set value hash */
*value_hash = core_option_manager_hash_string(value);
option->vals->elems[i].userdata = (void*)value_hash;
@@ -1001,6 +1004,9 @@ static bool core_option_manager_parse_option(
uint32_t *value_hash = (uint32_t *)malloc(sizeof(uint32_t));
const char *value_label = values[i].label;
if (!value_hash)
return false;
/* Append value string
* > We know that 'value' is always valid */
string_list_append(option->vals, value, attr);
+2
View File
@@ -1395,6 +1395,8 @@ static void runahead_input_state_set_last(
mylist_create(&runloop_st->input_state_list, 16,
input_list_element_constructor,
input_list_element_destructor);
if (!runloop_st->input_state_list)
return;
/* Find list item */
for (i = 0; i < (unsigned)runloop_st->input_state_list->size; i++)