mixer: Fix resource leaks
authorChris Michael <cp.michael@samsung.com>
Fri, 26 Jun 2015 14:25:42 +0000 (10:25 -0400)
committerChris Michael <cp.michael@samsung.com>
Fri, 26 Jun 2015 14:25:42 +0000 (10:25 -0400)
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 <cp.michael@samsung.com>
src/modules/mixer/lib/backends/pulseaudio/pulse.c

index f0a04a7..382ccfc 100644 (file)
@@ -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);