global: handle id allocation errors

This commit is contained in:
Wim Taymans 2022-01-13 21:22:25 +01:00
parent 892f27ded3
commit e241febe62

View file

@ -98,12 +98,17 @@ pw_global_new(struct pw_context *context,
spa_list_init(&this->resource_list); spa_list_init(&this->resource_list);
spa_hook_list_init(&this->listener_list); spa_hook_list_init(&this->listener_list);
pw_context_add_global(context, this); if (pw_context_add_global(context, this) == SPA_ID_INVALID) {
res = -ENOMEM;
goto error_free;
}
pw_log_debug("%p: new %s %d", this, this->type, this->id); pw_log_debug("%p: new %s %d", this, this->type, this->id);
return this; return this;
error_free:
free(this);
error_cleanup: error_cleanup:
pw_properties_free(properties); pw_properties_free(properties);
errno = -res; errno = -res;