media-session: don't write to freed memory in sm_object_destroy

Unref of node->handle may also free obj, if it was created by
init_object.
This commit is contained in:
Pauli Virtanen 2021-01-09 20:36:38 +02:00
parent 7ae1ea1420
commit d87f838e09

View file

@ -317,13 +317,13 @@ int sm_object_destroy(struct sm_object *obj)
spa_list_remove(&d->link); spa_list_remove(&d->link);
free(d); free(d);
} }
if (p)
pw_proxy_unref(p);
if (h)
pw_proxy_unref(h);
obj->proxy = NULL; obj->proxy = NULL;
obj->handle = NULL; obj->handle = NULL;
if (p)
pw_proxy_unref(p);
if (h)
pw_proxy_unref(h); /* may free obj, if from init_object */
return 0; return 0;
} }