diff options
author | rmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-08 16:51:51 +0000 |
---|---|---|
committer | rmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-08 16:51:51 +0000 |
commit | 2309381fc014ed1b91624d839e5c07aefaef348e (patch) | |
tree | 789a264b3a0203ac863939efb2e0b2e086453c14 | |
parent | a3f4551bd24e4407975a0726e110aa9640e03255 (diff) |
Merged revisions 222799 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r222799 | rmudgett | 2009-10-08 11:44:33 -0500 (Thu, 08 Oct 2009) | 19 lines
Merged revisions 222797 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r222797 | rmudgett | 2009-10-08 11:33:06 -0500 (Thu, 08 Oct 2009) | 12 lines
Fix memory leak if chan_misdn config parameter is repeated.
Memory leak when the same config option is set more than once in an
misdn.conf section. Why must this be considered? Templates! Defining a
template with default port options and later adding to or overriding some
of them.
Patches:
memleak-misdn.patch
JIRA ABE-1998
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@222802 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/misdn_config.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/channels/misdn_config.c b/channels/misdn_config.c index 8aa9a0acf..4a90bbec1 100644 --- a/channels/misdn_config.c +++ b/channels/misdn_config.c @@ -875,6 +875,9 @@ static int _parse (union misdn_cfg_pt *dest, const char *value, enum misdn_cfg_t switch (type) { case MISDN_CTYPE_STR: + if (dest->str) { + ast_free(dest->str); + } if ((len = strlen(value))) { dest->str = ast_malloc((len + 1) * sizeof(char)); strncpy(dest->str, value, len); @@ -894,18 +897,24 @@ static int _parse (union misdn_cfg_pt *dest, const char *value, enum misdn_cfg_t res = sscanf(value, "%30d", &tmp); } if (res) { - dest->num = ast_malloc(sizeof(int)); + if (!dest->num) { + dest->num = ast_malloc(sizeof(int)); + } memcpy(dest->num, &tmp, sizeof(int)); } else re = -1; } break; case MISDN_CTYPE_BOOL: - dest->num = ast_malloc(sizeof(int)); + if (!dest->num) { + dest->num = ast_malloc(sizeof(int)); + } *(dest->num) = (ast_true(value) ? 1 : 0); break; case MISDN_CTYPE_BOOLINT: - dest->num = ast_malloc(sizeof(int)); + if (!dest->num) { + dest->num = ast_malloc(sizeof(int)); + } if (sscanf(value, "%30d", &tmp)) { memcpy(dest->num, &tmp, sizeof(int)); } else { @@ -924,7 +933,9 @@ static int _parse (union misdn_cfg_pt *dest, const char *value, enum misdn_cfg_t } break; case MISDN_CTYPE_ASTGROUP: - dest->grp = ast_malloc(sizeof(ast_group_t)); + if (!dest->grp) { + dest->grp = ast_malloc(sizeof(ast_group_t)); + } *(dest->grp) = ast_get_group(value); break; } |