mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
prevent mem leak (bug #4842)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@6286 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -108,6 +108,21 @@ AST_MUTEX_DEFINE_STATIC(moh_lock);
|
||||
#define MPG_123 "/usr/bin/mpg123"
|
||||
#define MAX_MP3S 256
|
||||
|
||||
|
||||
static void ast_moh_free_class(struct mohclass **class)
|
||||
{
|
||||
struct mohdata *members, *mtmp;
|
||||
|
||||
members = (*class)->members;
|
||||
while(members) {
|
||||
mtmp = members;
|
||||
members = members->next;
|
||||
free(mtmp);
|
||||
}
|
||||
free(*class);
|
||||
*class = NULL;
|
||||
}
|
||||
|
||||
static int spawn_mp3(struct mohclass *class)
|
||||
{
|
||||
int fds[2];
|
||||
@@ -574,12 +589,12 @@ static int moh_register(char *classname, char *mode, char *param, char *miscargs
|
||||
ast_log(LOG_WARNING, "Unable to create moh...\n");
|
||||
if (moh->pseudofd > -1)
|
||||
close(moh->pseudofd);
|
||||
free(moh);
|
||||
ast_moh_free_class(&moh);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Don't know how to do a mode '%s' music on hold\n", mode);
|
||||
free(moh);
|
||||
ast_moh_free_class(&moh);
|
||||
return -1;
|
||||
}
|
||||
ast_mutex_lock(&moh_lock);
|
||||
|
Reference in New Issue
Block a user