# HG changeset patch # User reimar # Date 1141832393 0 # Node ID 16c347e53841bb977451bff1fc39f4895e4d5792 # Parent 031185213fa919aba65b0bfd91ea8ed8b933b7dc fix memory leak when filter with given name does not exist. Also prints which filter failed in the malloc-failed case diff -r 031185213fa9 -r 16c347e53841 libaf/af.c --- 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);