From e9aff3040ad5d279438d40d78969dd52d5bce6c3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 7 May 2026 13:30:12 +0200 Subject: [PATCH] modules: free the stream and impl on errors --- src/modules/module-rtp/stream.c | 8 ++++++-- src/modules/module-vban/stream.c | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modules/module-rtp/stream.c b/src/modules/module-rtp/stream.c index 11bba4f98..40d6dcf58 100644 --- a/src/modules/module-rtp/stream.c +++ b/src/modules/module-rtp/stream.c @@ -926,8 +926,7 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core, spa_dll_set_bw(&impl->dll, SPA_DLL_BW_MIN, 128, impl->rate); impl->corr = 1.0; - impl->stream = pw_stream_new(core, "rtp-session", props); - props = NULL; + impl->stream = pw_stream_new(core, "rtp-session", spa_steal_ptr(props)); if (impl->stream == NULL) { res = -errno; pw_log_error("can't create stream: %m"); @@ -1014,6 +1013,11 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core, return (struct rtp_stream*)impl; out: pw_properties_free(props); + if (impl) { + if (impl->stream) + pw_stream_destroy(impl->stream); + free(impl); + } errno = -res; return NULL; } diff --git a/src/modules/module-vban/stream.c b/src/modules/module-vban/stream.c index 168ecc837..28c699d17 100644 --- a/src/modules/module-vban/stream.c +++ b/src/modules/module-vban/stream.c @@ -250,7 +250,6 @@ struct vban_stream *vban_stream_new(struct pw_core *core, if (impl == NULL) { res = -errno; goto out; - return NULL; } impl->first = true; spa_hook_list_init(&impl->listener_list); @@ -388,8 +387,7 @@ struct vban_stream *vban_stream_new(struct pw_core *core, spa_dll_set_bw(&impl->dll, SPA_DLL_BW_MAX, 128, impl->rate); impl->corr = 1.0; - impl->stream = pw_stream_new(core, "vban-session", props); - props = NULL; + impl->stream = pw_stream_new(core, "vban-session", spa_steal_ptr(props)); if (impl->stream == NULL) { res = -errno; pw_log_error("can't create stream: %m"); @@ -443,6 +441,11 @@ struct vban_stream *vban_stream_new(struct pw_core *core, return (struct vban_stream*)impl; out: pw_properties_free(props); + if (impl) { + if (impl->stream) + pw_stream_destroy(impl->stream); + free(impl); + } errno = -res; return NULL; }