aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-14 22:42:17 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-14 22:42:17 +0000
commit89864095c8d4436d98f75d4a1c338b3c96fede1f (patch)
treeeb21c5f9de5ae6021204bac80e1e8380749c999e /res
parent04b34fd8e132320704f5f7daebba3948d93b2a3d (diff)
Merged revisions 149199 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r149199 | tilghman | 2008-10-14 17:38:06 -0500 (Tue, 14 Oct 2008) | 8 lines Add additional memory debugging to several core APIs, and fix several memory leaks found with these changes. (Closes issue #13505, closes issue #13543) Reported by: mav3rick, triccyx Patches: 20081001__bug13505.diff.txt uploaded by Corydon76 (license 14) Tested by: mav3rick, triccyx ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@149202 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_indications.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/res/res_indications.c b/res/res_indications.c
index af56444cd..ff2e2c9bc 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -249,6 +249,23 @@ static int handle_stopplaytones(struct ast_channel *chan, void *data)
return 0;
}
+/* helper function to delete a tone_zone in its entirety */
+static inline void free_zone(struct ind_tone_zone* zone)
+{
+ while (zone->tones) {
+ struct ind_tone_zone_sound *tmp = zone->tones->next;
+ ast_free((void *)zone->tones->name);
+ ast_free((void *)zone->tones->data);
+ ast_free(zone->tones);
+ zone->tones = tmp;
+ }
+
+ if (zone->ringcadence)
+ ast_free(zone->ringcadence);
+
+ ast_free(zone);
+}
+
/*! \brief load indications module */
static int ind_load_module(int reload)
{
@@ -302,6 +319,7 @@ static int ind_load_module(int reload)
}
if (!(tmp = ast_realloc(tones->ringcadence, (tones->nrringcadence + 1) * sizeof(int)))) {
ast_config_destroy(cfg);
+ free_zone(tones);
return -1;
}
tones->ringcadence = tmp;
@@ -318,13 +336,14 @@ static int ind_load_module(int reload)
struct ind_tone_zone* azone;
if (!(azone = ast_calloc(1, sizeof(*azone)))) {
ast_config_destroy(cfg);
+ free_zone(tones);
return -1;
}
ast_copy_string(azone->country, country, sizeof(azone->country));
ast_copy_string(azone->alias, cxt, sizeof(azone->alias));
if (ast_register_indication_country(azone)) {
ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno);
- ast_free(tones);
+ free_zone(tones);
}
/* next item */
country = strsep(&c,",");
@@ -357,17 +376,20 @@ out: v = v->next;
if (tones->description[0] || tones->alias[0] || tones->tones) {
if (ast_register_indication_country(tones)) {
ast_log(LOG_WARNING, "Unable to register indication at line %d.\n",v->lineno);
- ast_free(tones);
+ free_zone(tones);
}
- } else ast_free(tones);
+ } else {
+ free_zone(tones);
+ }
cxt = ast_category_browse(cfg, cxt);
}
/* determine which country is the default */
country = ast_variable_retrieve(cfg,"general","country");
- if (!country || !*country || ast_set_indication_country(country))
+ if (ast_strlen_zero(country) || ast_set_indication_country(country)) {
ast_log(LOG_WARNING,"Unable to set the default country (for indication tones)\n");
+ }
ast_config_destroy(cfg);
return 0;