mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-07 11:58:10 +02:00
introspect: handle strdup failures
Abort and clean up the dict copy when allocation fails.
This commit is contained in:
parent
dd695ee5a7
commit
379b4a8747
1 changed files with 8 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue