[pulseaudio-discuss] [PATCH] raop: Fix a memory leak
Peter Meerwald
pmeerw at pmeerw.net
Wed Nov 19 13:34:17 PST 2014
> a.path_or_host wasn't freed after calling pa_parse_address().
ack
> ---
>
> I needed pa_parse_address() in my module-tunnel-manager work, and I
> found the interface to be prone to memory leaks, so I decided to
> check all call sites of the function. I found one leak. I've added it
> to my todo list to make the function interface safer, but I don't
> expect to get around to that task any time soon, so if anyone else
> wants to fix it, be my guest.
>
>
> src/modules/raop/raop_client.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c
> index 5bb0bb4..7a6d009 100644
> --- a/src/modules/raop/raop_client.c
> +++ b/src/modules/raop/raop_client.c
> @@ -372,14 +372,19 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char* host) {
> pa_assert(core);
> pa_assert(host);
>
> - if (pa_parse_address(host, &a) < 0 || a.type == PA_PARSED_ADDRESS_UNIX)
> + if (pa_parse_address(host, &a) < 0)
> return NULL;
>
> + if (a.type == PA_PARSED_ADDRESS_UNIX) {
> + pa_xfree(a.path_or_host);
> + return NULL;
> + }
> +
> c = pa_xnew0(pa_raop_client, 1);
> c->core = core;
> c->fd = -1;
>
> - c->host = pa_xstrdup(a.path_or_host);
> + c->host = a.path_or_host;
> if (a.port)
> c->port = a.port;
> else
> --
> 1.9.3
>
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>
--
Peter Meerwald
+43-664-2444418 (mobile)
More information about the pulseaudio-discuss
mailing list