changeset 17780:16c347e53841

fix memory leak when filter with given name does not exist. Also prints which filter failed in the malloc-failed case
author reimar
date Wed, 08 Mar 2006 15:39:53 +0000
parents 031185213fa9
children d9474f04cce5
files libaf/af.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af.c	Wed Mar 08 15:21:12 2006 +0000
+++ b/libaf/af.c	Wed Mar 08 15:39:53 2006 +0000
@@ -104,7 +104,7 @@
   af_instance_t* new=malloc(sizeof(af_instance_t));
   if(!new){
     af_msg(AF_MSG_ERROR,"[libaf] Could not allocate memory\n");
-    return NULL;
+    goto err_out;
   }  
   memset(new,0,sizeof(af_instance_t));
 
@@ -113,7 +113,7 @@
 
   // Find filter from name
   if(NULL == (new->info=af_find(name)))
-    return NULL;
+    goto err_out;
 
   /* Make sure that the filter is not already in the list if it is
      non-reentrant */
@@ -121,8 +121,7 @@
     if(af_get(s,name)){
       af_msg(AF_MSG_ERROR,"[libaf] There can only be one instance of" 
 	     " the filter '%s' in each stream\n",name);  
-      free(new);
-      return NULL;
+      goto err_out;
     }
   }
   
@@ -139,6 +138,7 @@
       return new; 
   }
   
+err_out:
   free(new);
   af_msg(AF_MSG_ERROR,"[libaf] Couldn't create or open audio filter '%s'\n",
 	 name);