From 3a395b4223960ac2554bfd90e0e891ba4423ad93 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Fri, 26 Jun 2015 10:25:42 -0400 Subject: [PATCH] mixer: Fix resource leaks This fixes Coverity CID1308395: Resource leak. Basically, don't bother allocating 'source' if we are just going to end up returning due to 'eol' variable tests Signed-off-by: Chris Michael --- src/modules/mixer/lib/backends/pulseaudio/pulse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/mixer/lib/backends/pulseaudio/pulse.c b/src/modules/mixer/lib/backends/pulseaudio/pulse.c index f0a04a76d..382ccfcdf 100644 --- a/src/modules/mixer/lib/backends/pulseaudio/pulse.c +++ b/src/modules/mixer/lib/backends/pulseaudio/pulse.c @@ -422,9 +422,6 @@ _source_cb(pa_context *c EINA_UNUSED, const pa_source_info *info, Source *source; EINA_SAFETY_ON_NULL_RETURN(ctx); - source = calloc(1, sizeof(Source)); - EINA_SAFETY_ON_NULL_RETURN(source); - if (eol < 0) { if (pa_context_errno(c) == PA_ERR_NOENTITY) @@ -437,6 +434,9 @@ _source_cb(pa_context *c EINA_UNUSED, const pa_source_info *info, if (eol > 0) return; + source = calloc(1, sizeof(Source)); + EINA_SAFETY_ON_NULL_RETURN(source); + source->idx = info->index; source->base.name = eina_stringshare_add(info->name); source->base.volume = _pa_cvolume_convert(info->volume);