aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2009-07-14 00:48:59 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2009-07-14 00:48:59 +0000
commit8db28e34c5ad499105c008be5461d77e7fe4fd76 (patch)
tree2d0f5b14dfb68e8a9eb7266868681fbdb38e1733
parentb8e52a3435e282cbf9a07b6a9f97bbf52580dda9 (diff)
Merged revisions 206284 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r206284 | rmudgett | 2009-07-13 19:17:28 -0500 (Mon, 13 Jul 2009) | 4 lines Fix some memory leaks in chan_misdn. JIRA ABE-1911 ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@206341 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_misdn.c64
-rw-r--r--channels/misdn/isdn_lib.c4
2 files changed, 47 insertions, 21 deletions
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index cb23646bd..5be536abf 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -610,23 +610,18 @@ struct robin_list {
static struct robin_list *robin = NULL;
-static inline void free_robin_list_r(struct robin_list *r)
+static void free_robin_list(void)
{
- if (r) {
- if (r->next)
- free_robin_list_r(r->next);
- if (r->group)
- ast_free(r->group);
+ struct robin_list *r;
+ struct robin_list *next;
+
+ for (r = robin, robin = NULL; r; r = next) {
+ next = r->next;
+ ast_free(r->group);
ast_free(r);
}
}
-static void free_robin_list(void)
-{
- free_robin_list_r(robin);
- robin = NULL;
-}
-
static struct robin_list *get_robin_position(char *group)
{
struct robin_list *new;
@@ -637,7 +632,14 @@ static struct robin_list *get_robin_position(char *group)
}
}
new = ast_calloc(1, sizeof(*new));
- new->group = strdup(group);
+ if (!new) {
+ return NULL;
+ }
+ new->group = ast_strdup(group);
+ if (!new->group) {
+ ast_free(new);
+ return NULL;
+ }
new->channel = 1;
if (robin) {
new->next = robin;
@@ -7694,6 +7696,7 @@ static struct ast_channel *misdn_request(const char *type, int format, const str
ast = misdn_new(cl, AST_STATE_RESERVED, args.ext, NULL, format, requestor ? requestor->linkedid : NULL, port, channel);
if (!ast) {
+ ast_free(cl);
ast_log(LOG_ERROR, "Could not create Asterisk channel for Dial(%s)\n", dial_str);
return NULL;
}
@@ -9581,6 +9584,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
chan = misdn_new(ch, AST_STATE_RESERVED, bc->dialed.number, bc->caller.number, AST_FORMAT_ALAW, NULL, bc->port, bc->channel);
if (!chan) {
+ ast_free(ch);
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
ast_log(LOG_ERROR, "cb_events: misdn_new failed !\n");
return 0;
@@ -10553,13 +10557,11 @@ static int unload_module(void)
misdn_cfg_destroy();
misdn_lib_destroy();
- if (misdn_debug) {
- ast_free(misdn_debug);
- }
- if (misdn_debug_only) {
- ast_free(misdn_debug_only);
- }
- ast_free(misdn_ports);
+ ast_free(misdn_out_calls);
+ ast_free(misdn_in_calls);
+ ast_free(misdn_debug_only);
+ ast_free(misdn_ports);
+ ast_free(misdn_debug);
#if defined(AST_MISDN_ENHANCEMENTS)
misdn_cc_destroy();
@@ -10605,6 +10607,7 @@ static int load_module(void)
}
misdn_ports = ast_malloc(sizeof(int) * (max_ports + 1));
if (!misdn_ports) {
+ ast_free(misdn_debug);
ast_log(LOG_ERROR, "Out of memory for misdn_ports\n");
return AST_MODULE_LOAD_DECLINE;
}
@@ -10615,6 +10618,12 @@ static int load_module(void)
}
*misdn_ports = 0;
misdn_debug_only = ast_calloc(max_ports + 1, sizeof(int));
+ if (!misdn_debug_only) {
+ ast_free(misdn_ports);
+ ast_free(misdn_debug);
+ ast_log(LOG_ERROR, "Out of memory for misdn_debug_only\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
misdn_cfg_get(0, MISDN_GEN_TRACEFILE, tempbuf, sizeof(tempbuf));
if (!ast_strlen_zero(tempbuf)) {
@@ -10622,7 +10631,22 @@ static int load_module(void)
}
misdn_in_calls = ast_malloc(sizeof(int) * (max_ports + 1));
+ if (!misdn_in_calls) {
+ ast_free(misdn_debug_only);
+ ast_free(misdn_ports);
+ ast_free(misdn_debug);
+ ast_log(LOG_ERROR, "Out of memory for misdn_in_calls\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
misdn_out_calls = ast_malloc(sizeof(int) * (max_ports + 1));
+ if (!misdn_out_calls) {
+ ast_free(misdn_in_calls);
+ ast_free(misdn_debug_only);
+ ast_free(misdn_ports);
+ ast_free(misdn_debug);
+ ast_log(LOG_ERROR, "Out of memory for misdn_out_calls\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
for (i = 1; i <= max_ports; i++) {
misdn_in_calls[i] = 0;
diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c
index 47da58378..10590d64f 100644
--- a/channels/misdn/isdn_lib.c
+++ b/channels/misdn/isdn_lib.c
@@ -2954,9 +2954,11 @@ static int handle_l2(msg_t *msg)
case DL_ESTABLISH | REQUEST:
cb_log(1,stack->port,"DL_ESTABLISH|REQUEST \n");
+ free_msg(msg);
return 1;
case DL_RELEASE | REQUEST:
cb_log(1,stack->port,"DL_RELEASE|REQUEST \n");
+ free_msg(msg);
return 1;
case DL_ESTABLISH | INDICATION:
@@ -4191,7 +4193,7 @@ static void manager_event_handler(void *arg)
free_msg(msg);
break;
case MGR_SETSTACK | REQUEST :
- /* Warning: memory leak here if we get this message */
+ free_msg(msg);
break;
default:
mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);