diff --git a/src/pipewire/introspect.c b/src/pipewire/introspect.c index 098a442b4..396250b58 100644 --- a/src/pipewire/introspect.c +++ b/src/pipewire/introspect.c @@ -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; }