properties: Fix memory leak

Do not initialize changes in update_string() if
spa_json_begin_object_relax() fails to avoid having to clear changes
before returning.
This commit is contained in:
Jonas Holmberg 2024-09-27 11:55:42 +02:00
parent d8f0cc7817
commit 648badb427

View file

@ -218,12 +218,12 @@ static int update_string(struct pw_properties *props, const char *str, size_t si
struct properties changes;
const char *value;
if (props)
properties_init(&changes, 16);
if ((res = spa_json_begin_object_relax(&it[0], str, size)) <= 0)
return res;
if (props)
properties_init(&changes, 16);
while ((len = spa_json_object_next(&it[0], key, sizeof(key), &value)) > 0) {
char *val = NULL;