From 9946f5ec7753a696f32123d5e955667be3a1608d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 5 May 2026 14:14:52 +0200 Subject: [PATCH] modules: handle some more allocation errors --- src/modules/module-sendspin-recv.c | 10 ++++++++++ src/modules/module-sendspin-send.c | 10 ++++++++++ src/modules/module-vban-recv.c | 4 ++++ src/pipewire/impl-factory.c | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/src/modules/module-sendspin-recv.c b/src/modules/module-sendspin-recv.c index 793e16441..9380165f2 100644 --- a/src/modules/module-sendspin-recv.c +++ b/src/modules/module-sendspin-recv.c @@ -352,6 +352,8 @@ static int create_stream(struct client *client) struct spa_pod_builder b; const char *server_id, *ip, *port, *server_name; struct pw_properties *props = pw_properties_copy(client->props); + if (props == NULL) + return -errno; ip = pw_properties_get(props, "sendspin.ip"); port = pw_properties_get(props, "sendspin.port"); @@ -1090,6 +1092,8 @@ static void on_websocket_connected(void *data, void *user, (struct sockaddr*)&addr, sizeof(addr)); props = pw_properties_copy(impl->stream_props); + if (props == NULL) + return; if (pw_net_get_ip(&addr, ip, sizeof(ip), &ipv4, &port) >= 0) { pw_properties_set(props, "sendspin.ip", ip); pw_properties_setf(props, "sendspin.port", "%u", port); @@ -1137,6 +1141,8 @@ static void on_zeroconf_added(void *data, const void *user, const struct spa_dic return; props = pw_properties_copy(impl->stream_props); + if (props == NULL) + return; pw_properties_update(props, info); addr = spa_dict_lookup(info, PW_KEY_ZEROCONF_ADDRESS); @@ -1377,6 +1383,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) path = DEFAULT_SENDSPIN_PATH; p = pw_properties_copy(impl->stream_props); + if (p == NULL) { + res = -errno; + goto out; + } pw_properties_set(p, "sendspin.ip", hostname); pw_properties_set(p, "sendspin.port", port); pw_properties_set(p, "sendspin.path", path); diff --git a/src/modules/module-sendspin-send.c b/src/modules/module-sendspin-send.c index 29ae51592..c47497656 100644 --- a/src/modules/module-sendspin-send.c +++ b/src/modules/module-sendspin-send.c @@ -378,6 +378,8 @@ static int create_stream(struct client *c) struct spa_pod_builder b; const char *client_id, *ip, *port, *client_name; struct pw_properties *props = pw_properties_copy(c->props); + if (props == NULL) + return -errno; ip = pw_properties_get(props, "sendspin.ip"); port = pw_properties_get(props, "sendspin.port"); @@ -1136,6 +1138,8 @@ static void on_websocket_connected(void *data, void *user, (struct sockaddr*)&addr, sizeof(addr)); props = pw_properties_copy(impl->stream_props); + if (props == NULL) + return; if (pw_net_get_ip(&addr, ip, sizeof(ip), &ipv4, &port) >= 0) { pw_properties_set(props, "sendspin.ip", ip); pw_properties_setf(props, "sendspin.port", "%u", port); @@ -1177,6 +1181,8 @@ static void on_zeroconf_added(void *data, const void *user, const struct spa_dic return; props = pw_properties_copy(impl->stream_props); + if (props == NULL) + return; pw_properties_update(props, info); addr = spa_dict_lookup(info, PW_KEY_ZEROCONF_ADDRESS); @@ -1405,6 +1411,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) while (spa_json_get_string(&iter, v, sizeof(v)) > 0) { struct client *c; struct pw_properties *p = pw_properties_copy(impl->stream_props); + if (p == NULL) { + res = -errno; + goto out; + } pw_properties_set(p, "sendspin.ip", v); pw_properties_set(p, "sendspin.port", port); diff --git a/src/modules/module-vban-recv.c b/src/modules/module-vban-recv.c index 2ee724305..f0733c498 100644 --- a/src/modules/module-vban-recv.c +++ b/src/modules/module-vban-recv.c @@ -353,6 +353,8 @@ static int rule_matched(void *data, const char *location, const char *action, i->matched = true; if (spa_streq(action, "create-stream")) { struct pw_properties *p = pw_properties_copy(i->props); + if (p == NULL) + return -errno; pw_properties_update_string(p, str, len); create_stream(i->stream, p); } @@ -373,6 +375,8 @@ do_setup_stream(struct spa_loop *loop, uint16_t port = 0; props = pw_properties_copy(impl->stream_props); + if (props == NULL) + return -errno; pw_net_get_ip(&s->sa, addr, sizeof(addr), NULL, &port); diff --git a/src/pipewire/impl-factory.c b/src/pipewire/impl-factory.c index 99900db47..1301dbaed 100644 --- a/src/pipewire/impl-factory.c +++ b/src/pipewire/impl-factory.c @@ -43,6 +43,10 @@ struct pw_impl_factory *pw_context_create_factory(struct pw_context *context, this->properties = properties; this->info.name = strdup(name); + if (this->info.name == NULL) { + res = -errno; + goto error_free; + } this->info.type = type; this->info.version = version; this->info.props = &properties->dict; @@ -55,6 +59,8 @@ struct pw_impl_factory *pw_context_create_factory(struct pw_context *context, return this; +error_free: + free(this); error_exit: pw_properties_free(properties); errno = -res;