From 5459c759ee919735eee0de275a35570eca21ffd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 16 Jun 2021 22:15:02 +0200 Subject: [PATCH] pipewire: properties: move value equality check --- src/pipewire/properties.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index a513253bc..b09987924 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -411,23 +411,27 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v if (item == NULL) { if (value == NULL) return 0; + add_item(properties, strdup(key), copy ? strdup(value) : value); } else { - if (value && spa_streq(item->value, value)) - goto exit_noupdate; + if (value != NULL) { + if (spa_streq(item->value, value)) + goto exit_noupdate; - if (value == NULL) { - clear_item(item); - remove_item(properties, item); - } else { free((char *) item->value); item->value = copy ? strdup(value) : value; + } else { + clear_item(item); + remove_item(properties, item); } } + return 1; + exit_noupdate: if (!copy) free(value); + return 0; }