diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index cb6f7c851..b8a8aa333 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -523,7 +523,7 @@ do_update_port(struct node *this, port->params = realloc(port->params, port->n_params * sizeof(struct spa_pod *)); for (i = 0; i < port->n_params; i++) { - port->params[i] = pw_spa_pod_copy(params[i]); + port->params[i] = params[i] ? pw_spa_pod_copy(params[i]) : NULL; if (spa_pod_is_object_id(port->params[i], SPA_PARAM_Format)) port->have_format = true; @@ -1028,7 +1028,7 @@ client_node_update(void *data, this->params = realloc(this->params, this->n_params * sizeof(struct spa_pod *)); for (i = 0; i < this->n_params; i++) - this->params[i] = pw_spa_pod_copy(params[i]); + this->params[i] = params[i] ? pw_spa_pod_copy(params[i]) : NULL; } if (change_mask & PW_CLIENT_NODE_UPDATE_PROPS) { pw_node_update_properties(impl->this.node, props); diff --git a/src/pipewire/introspect.c b/src/pipewire/introspect.c index 9e0ad7dc5..a688d45f5 100644 --- a/src/pipewire/introspect.c +++ b/src/pipewire/introspect.c @@ -423,7 +423,7 @@ struct pw_link_info *pw_link_info_update(struct pw_link_info *info, } if (update->change_mask & PW_LINK_CHANGE_MASK_FORMAT) { free(info->format); - info->format = pw_spa_pod_copy(update->format); + info->format = update->format ? pw_spa_pod_copy(update->format) : NULL; } if (update->change_mask & PW_LINK_CHANGE_MASK_PROPS) { if (info->props) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 07a9aebcc..9fefa0f6c 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -140,13 +140,18 @@ static struct param *add_param(struct pw_stream *stream, { struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct param *p; + struct spa_pod *copy = NULL; - p = pw_array_add(&impl->params, sizeof(struct param)); - if (p == NULL) + if (param != NULL && (copy = pw_spa_pod_copy(param)) == NULL) return NULL; + p = pw_array_add(&impl->params, sizeof(struct param)); + if (p == NULL) { + free(copy); + return NULL; + } p->type = type; - p->param = pw_spa_pod_copy(param); + p->param = copy; return p; } diff --git a/src/pipewire/utils.h b/src/pipewire/utils.h index 8e7f875df..fe17d3dce 100644 --- a/src/pipewire/utils.h +++ b/src/pipewire/utils.h @@ -59,9 +59,6 @@ pw_spa_pod_copy(const struct spa_pod *pod) size_t size; struct spa_pod *c; - if (pod == NULL) - return NULL; - size = SPA_POD_SIZE(pod); if ((c = (struct spa_pod *) malloc(size)) == NULL) return NULL;