discomfitor pushed a commit to branch enlightenment-0.21.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=457843b005974a6f86f191c6ae8043124d42ee85

commit 457843b005974a6f86f191c6ae8043124d42ee85
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Tue Jul 11 10:45:26 2017 +0900

    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 e07e8a674..3c9c96338 100644
--- a/src/modules/mixer/lib/backends/pulseaudio/pulse.c
+++ b/src/modules/mixer/lib/backends/pulseaudio/pulse.c
@@ -337,6 +337,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)

-- 


Reply via email to