introspect: handle strdup failures

Abort and clean up the dict copy when allocation fails.
This commit is contained in:
Wim Taymans 2026-05-05 13:50:39 +02:00
parent dd695ee5a7
commit 379b4a8747

View file

@ -94,12 +94,18 @@ static struct spa_dict *pw_spa_dict_copy(struct spa_dict *dict)
for (i = 0; i < dict->n_items; i++) {
items[i].key = strdup(dict->items[i].key);
items[i].value = dict->items[i].value ? strdup(dict->items[i].value) : NULL;
if (items[i].key == NULL ||
(dict->items[i].value != NULL && items[i].value == NULL))
goto no_key;
}
return copy;
no_items:
no_key:
pw_spa_dict_destroy(copy);
return NULL;
no_items:
free(copy);
no_mem:
no_mem:
return NULL;
}