[svn-commits] may: trunk r307677 - in /trunk/addons: chan_ooh323.c ooh323cDriver.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sat Feb 12 17:26:02 CST 2011
Author: may
Date: Sat Feb 12 17:25:58 2011
New Revision: 307677
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=307677
Log:
change malloc to ast_calloc calls to prevent crash of asterisk
Modified:
trunk/addons/chan_ooh323.c
trunk/addons/ooh323cDriver.c
Modified: trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/chan_ooh323.c?view=diff&rev=307677&r1=307676&r2=307677
==============================================================================
--- trunk/addons/chan_ooh323.c (original)
+++ trunk/addons/chan_ooh323.c Sat Feb 12 17:25:58 2011
@@ -701,7 +701,7 @@
ast_mutex_unlock(&iflock);
} else {
ast_mutex_lock(&p->lock);
- p->callToken = (char*)ast_malloc(AST_MAX_EXTENSION);
+ p->callToken = (char*)ast_calloc(1, AST_MAX_EXTENSION);
if(!p->callToken) {
ast_mutex_unlock(&p->lock);
ast_mutex_lock(&iflock);
@@ -1433,7 +1433,7 @@
ast_mutex_lock(&p->lock);
- ast_format_copy(&p->writeformat, fmt);
+ ast_format_copy(&(p->writeformat), fmt);
if (p->owner) {
while (p->owner && ast_channel_trylock(p->owner)) {
@@ -1491,7 +1491,7 @@
ast_mutex_lock(&p->lock);
- ast_format_copy(&p->readformat, fmt);
+ ast_format_copy(&(p->readformat), fmt);
if (p->owner) {
while (p->owner && ast_channel_trylock(p->owner)) {
@@ -2183,7 +2183,7 @@
user = ast_calloc(1,sizeof(struct ooh323_user));
if (user) {
memset(user, 0, sizeof(struct ooh323_user));
- if (!(user->cap = ast_format_cap_alloc_nolock())) {
+ if (!(user->cap = ast_format_cap_alloc())) {
ast_free(user);
return NULL;
}
@@ -2223,7 +2223,7 @@
if (user->rtptimeout < 0)
user->rtptimeout = gRTPTimeout;
} else if (!strcasecmp(v->name, "rtpmask")) {
- if ((user->rtpmask = malloc(sizeof(struct OOH323Regex))) &&
+ if ((user->rtpmask = ast_calloc(1, sizeof(struct OOH323Regex))) &&
(regcomp(&user->rtpmask->regex, v->value, REG_EXTENDED)
== 0)) {
ast_mutex_init(&user->rtpmask->lock);
@@ -2296,7 +2296,7 @@
peer = ast_calloc(1, sizeof(*peer));
if (peer) {
memset(peer, 0, sizeof(struct ooh323_peer));
- if (!(peer->cap = ast_format_cap_alloc_nolock())) {
+ if (!(peer->cap = ast_format_cap_alloc())) {
ast_free(peer);
return NULL;
}
@@ -2367,7 +2367,7 @@
if(peer->rtptimeout < 0)
peer->rtptimeout = gRTPTimeout;
} else if (!strcasecmp(v->name, "rtpmask")) {
- if ((peer->rtpmask = malloc(sizeof(struct OOH323Regex))) &&
+ if ((peer->rtpmask = ast_calloc(1, sizeof(struct OOH323Regex))) &&
(regcomp(&peer->rtpmask->regex, v->value, REG_EXTENDED)
== 0)) {
ast_mutex_init(&peer->rtpmask->lock);
@@ -2601,7 +2601,7 @@
else
ooH323EpTryBeMaster(0);
} else if (!strcasecmp(v->name, "h323id")) {
- pNewAlias = malloc(sizeof(struct ooAliases));
+ pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
if (!pNewAlias) {
ast_log(LOG_ERROR, "Failed to allocate memory for h323id alias\n");
return 1;
@@ -2615,7 +2615,7 @@
gAliasList = pNewAlias;
pNewAlias = NULL;
} else if (!strcasecmp(v->name, "e164")) {
- pNewAlias = malloc(sizeof(struct ooAliases));
+ pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
if (!pNewAlias) {
ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n");
return 1;
@@ -2626,7 +2626,7 @@
gAliasList = pNewAlias;
pNewAlias = NULL;
} else if (!strcasecmp(v->name, "email")) {
- pNewAlias = malloc(sizeof(struct ooAliases));
+ pNewAlias = ast_calloc(1, sizeof(struct ooAliases));
if (!pNewAlias) {
ast_log(LOG_ERROR, "Failed to allocate memory for email alias\n");
return 1;
@@ -3238,7 +3238,7 @@
.onModeChanged = onModeChanged
};
if (!(gCap = ast_format_cap_alloc())) {
- return 1;
+ return 1;
}
if (!(ooh323_tech.capabilities = ast_format_cap_alloc())) {
return 1;
@@ -4095,6 +4095,7 @@
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
ast_mutex_unlock(&p->lock);
+ free(callToken);
return 0;
}
Modified: trunk/addons/ooh323cDriver.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/ooh323cDriver.c?view=diff&rev=307677&r1=307676&r2=307677
==============================================================================
--- trunk/addons/ooh323cDriver.c (original)
+++ trunk/addons/ooh323cDriver.c Sat Feb 12 17:25:58 2011
@@ -145,7 +145,7 @@
/* make new thread */
if (cur == NULL) {
- if (!(cur = ast_malloc(sizeof(struct callthread)))) {
+ if (!(cur = ast_calloc(1, sizeof(struct callthread)))) {
ast_log(LOG_ERROR, "Unable to allocate thread structure for call %s\n",
call->callToken);
return -1;
More information about the svn-commits
mailing list