mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 16:33:34 +00:00
Fix several memory leaks
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2153 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3167,6 +3167,7 @@ static int load_config(void)
|
||||
while(cur) {
|
||||
l = cur;
|
||||
cur = cur->next;
|
||||
l->alloced = 1;
|
||||
free_user(l);
|
||||
}
|
||||
zcur = zones;
|
||||
|
@@ -5210,6 +5210,7 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
|
||||
{
|
||||
struct iax2_peer *peer;
|
||||
struct iax2_peer *prev;
|
||||
struct ast_ha *oldha = NULL;
|
||||
int maskfound=0;
|
||||
int format;
|
||||
int found=0;
|
||||
@@ -5225,6 +5226,8 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
|
||||
}
|
||||
if (peer) {
|
||||
found++;
|
||||
oldha = peer->ha;
|
||||
peer->ha = NULL;
|
||||
/* Already in the list, remove it and it will be added back (or FREE'd) */
|
||||
if (prev) {
|
||||
prev->next = peer->next;
|
||||
@@ -5351,6 +5354,8 @@ static struct iax2_peer *build_peer(char *name, struct ast_variable *v)
|
||||
if (!found && peer->dynamic)
|
||||
reg_source_db(peer);
|
||||
}
|
||||
if (oldha)
|
||||
ast_free_ha(oldha);
|
||||
return peer;
|
||||
}
|
||||
|
||||
@@ -5358,6 +5363,8 @@ static struct iax2_user *build_user(char *name, struct ast_variable *v)
|
||||
{
|
||||
struct iax2_user *prev, *user;
|
||||
struct iax2_context *con, *conl = NULL;
|
||||
struct ast_ha *oldha = NULL;
|
||||
struct iax2_context *oldcon = NULL;
|
||||
int format;
|
||||
int found;
|
||||
|
||||
@@ -5373,6 +5380,10 @@ static struct iax2_user *build_user(char *name, struct ast_variable *v)
|
||||
}
|
||||
if (user) {
|
||||
found++;
|
||||
oldha = user->ha;
|
||||
oldcon = user->contexts;
|
||||
user->ha = NULL;
|
||||
user->contexts = NULL;
|
||||
/* Already in the list, remove it and it will be added back (or FREE'd) */
|
||||
if (prev) {
|
||||
prev->next = user->next;
|
||||
@@ -5458,6 +5469,10 @@ static struct iax2_user *build_user(char *name, struct ast_variable *v)
|
||||
}
|
||||
user->delme = 0;
|
||||
}
|
||||
if (oldha)
|
||||
ast_free_ha(oldha);
|
||||
if (oldcon)
|
||||
free_context(oldcon);
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -5520,6 +5535,7 @@ static void prune_peers(void){
|
||||
for (peer=peerl.peers;peer;) {
|
||||
peernext = peer->next;
|
||||
if (peer->delme) {
|
||||
ast_free_ha(peer->ha);
|
||||
for (x=0;x<IAX_MAX_CALLS;x++) {
|
||||
ast_mutex_lock(&iaxsl[x]);
|
||||
if (iaxs[x] && (iaxs[x]->peerpoke == peer)) {
|
||||
|
@@ -318,6 +318,7 @@ static inline void free_zone(struct tone_zone* zone)
|
||||
struct tone_zone_sound *tmp = zone->tones->next;
|
||||
free((void*)zone->tones->name);
|
||||
free((void*)zone->tones->data);
|
||||
free((void*)zone->ringcadance);
|
||||
free(zone->tones);
|
||||
zone->tones = tmp;
|
||||
}
|
||||
@@ -395,6 +396,8 @@ int ast_unregister_indication_country(const char *country)
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Unregistered indication country '%s'\n",tz->country);
|
||||
free_zone(tz);
|
||||
if (tone_zones == tz)
|
||||
tone_zones = tmp;
|
||||
tz = tmp;
|
||||
res = 0;
|
||||
}
|
||||
|
8
pbx.c
8
pbx.c
@@ -4066,6 +4066,7 @@ void __ast_context_destroy(struct ast_context *con, char *registrar, int lock)
|
||||
struct ast_include *tmpi, *tmpil= NULL;
|
||||
struct ast_sw *sw, *swl= NULL;
|
||||
struct ast_exten *e, *el, *en;
|
||||
struct ast_ignorepat *ipi, *ipl = NULL;
|
||||
if (lock)
|
||||
ast_mutex_lock(&conlock);
|
||||
tmp = contexts;
|
||||
@@ -4090,7 +4091,12 @@ void __ast_context_destroy(struct ast_context *con, char *registrar, int lock)
|
||||
tmpil = tmpi;
|
||||
tmpi = tmpi->next;
|
||||
free(tmpil);
|
||||
tmpil = tmpi;
|
||||
}
|
||||
for (ipi = tmp->ignorepats; ipi; ) {
|
||||
/* Free includes */
|
||||
ipl = ipi;
|
||||
ipi = ipi->next;
|
||||
free(ipl);
|
||||
}
|
||||
for (sw = tmp->alts; sw; ) {
|
||||
swl = sw;
|
||||
|
Reference in New Issue
Block a user