1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00

fix memory leak when filter with given name does not exist.

Also prints which filter failed in the malloc-failed case


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17781 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2006-03-08 15:39:53 +00:00
parent 93ffd2ad79
commit 694f18ea46

View File

@ -104,7 +104,7 @@ af_instance_t* af_create(af_stream_t* s, char* name)
af_instance_t* new=malloc(sizeof(af_instance_t)); af_instance_t* new=malloc(sizeof(af_instance_t));
if(!new){ if(!new){
af_msg(AF_MSG_ERROR,"[libaf] Could not allocate memory\n"); af_msg(AF_MSG_ERROR,"[libaf] Could not allocate memory\n");
return NULL; goto err_out;
} }
memset(new,0,sizeof(af_instance_t)); memset(new,0,sizeof(af_instance_t));
@ -113,7 +113,7 @@ af_instance_t* af_create(af_stream_t* s, char* name)
// Find filter from name // Find filter from name
if(NULL == (new->info=af_find(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 /* Make sure that the filter is not already in the list if it is
non-reentrant */ non-reentrant */
@ -121,8 +121,7 @@ af_instance_t* af_create(af_stream_t* s, char* name)
if(af_get(s,name)){ if(af_get(s,name)){
af_msg(AF_MSG_ERROR,"[libaf] There can only be one instance of" af_msg(AF_MSG_ERROR,"[libaf] There can only be one instance of"
" the filter '%s' in each stream\n",name); " the filter '%s' in each stream\n",name);
free(new); goto err_out;
return NULL;
} }
} }
@ -139,6 +138,7 @@ af_instance_t* af_create(af_stream_t* s, char* name)
return new; return new;
} }
err_out:
free(new); free(new);
af_msg(AF_MSG_ERROR,"[libaf] Couldn't create or open audio filter '%s'\n", af_msg(AF_MSG_ERROR,"[libaf] Couldn't create or open audio filter '%s'\n",
name); name);