From b173ed7be6beee016d96d4c78eaad641507fbe2c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 11 Jul 2017 10:45:26 +0900 Subject: [PATCH] pulse: do not leak strbuf See also ac92ff52567293399060bfd35b22ae86fe. - eina_strbuf_string_get() returns the internally stored string as a const char *, and does not free the strbuf itself - eina_strbuf_string_steal() returns the internal string as a char *, giving ownership to the caller, and frees the strbuf itself - eina_stringshare_add() takes a const char * as input and makes a copy of the string As a consequence, ss_add(sb_string_steal()) leaks the internal string from the strbuf, while ss_add(sb_string_get()) leaks the strbuf structure. A one liner here would require either an eina_slstr based API or an API in stringshare to take ownership of a given string. Both would be useful APIs :) --- src/modules/mixer/lib/backends/pulseaudio/pulse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/mixer/lib/backends/pulseaudio/pulse.c b/src/modules/mixer/lib/backends/pulseaudio/pulse.c index 56446fcf4..ec1bdc1b4 100644 --- a/src/modules/mixer/lib/backends/pulseaudio/pulse.c +++ b/src/modules/mixer/lib/backends/pulseaudio/pulse.c @@ -338,6 +338,7 @@ _sink_input_cb(pa_context *c EINA_UNUSED, const pa_sink_input_info *info, eina_strbuf_append(input_name, ":"); eina_strbuf_append(input_name, info->name); input->base.name = eina_stringshare_add(eina_strbuf_string_get(input_name)); + eina_strbuf_free(input_name); input->base.volume = _pa_cvolume_convert(&info->volume); input->base.mute = !!info->mute; EINA_LIST_FOREACH(ctx->sinks, l, s)