pulse: do not leak strbuf

See also ac92ff5256.
- 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 :)
This commit is contained in:
Jean-Philippe Andre 2017-07-11 10:45:26 +09:00 committed by Mike Blumenkrantz
parent 1b49006b52
commit 457843b005
1 changed files with 1 additions and 0 deletions

View File

@ -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)