mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
core: Don't allow free to mean ast_free (and malloc, etc..).
This gets rid of most old libc free/malloc/realloc and replaces them with ast_free and friends. When compiling with MALLOC_DEBUG you'll notice it when you're mistakenly using one of the libc variants. For the legacy cases you can define WRAP_LIBC_MALLOC before including asterisk.h. Even better would be if the errors were also enabled when compiling without MALLOC_DEBUG, but that's a slightly more invasive header file change. Those compiling addons/format_mp3 will need to rerun ./contrib/scripts/get_mp3_source.sh. ASTERISK-24348 #related Review: https://reviewboard.asterisk.org/r/4015/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -538,7 +538,7 @@ static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken)
|
||||
|
||||
pvt->call_reference = callref;
|
||||
if (callToken)
|
||||
pvt->callToken = strdup(callToken);
|
||||
pvt->callToken = ast_strdup(callToken);
|
||||
|
||||
/* whether to use gk for this call */
|
||||
if (gRasGkMode == RasNoGatekeeper)
|
||||
@@ -645,8 +645,8 @@ static struct ast_channel *ooh323_request(const char *type, struct ast_format_ca
|
||||
}
|
||||
|
||||
if (peer) {
|
||||
p->username = strdup(peer->name);
|
||||
p->host = strdup(peer->ip);
|
||||
p->username = ast_strdup(peer->name);
|
||||
p->host = ast_strdup(peer->ip);
|
||||
p->port = peer->port;
|
||||
/* Disable gk as we are going to call a known peer*/
|
||||
/* OO_SETFLAG(p->flags, H323_DISABLEGK); */
|
||||
@@ -707,9 +707,9 @@ static struct ast_channel *ooh323_request(const char *type, struct ast_format_ca
|
||||
p->directrtp = gDirectRTP;
|
||||
p->earlydirect = gEarlyDirect;
|
||||
|
||||
p->username = strdup(dest);
|
||||
p->username = ast_strdup(dest);
|
||||
|
||||
p->host = strdup(dest);
|
||||
p->host = ast_strdup(dest);
|
||||
if (port > 0) {
|
||||
p->port = port;
|
||||
}
|
||||
@@ -964,22 +964,22 @@ static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout)
|
||||
ast_mutex_lock(&p->lock);
|
||||
ast_set_flag(p, H323_OUTGOING);
|
||||
if (ast_channel_connected(ast)->id.number.valid && ast_channel_connected(ast)->id.number.str) {
|
||||
free(p->callerid_num);
|
||||
p->callerid_num = strdup(ast_channel_connected(ast)->id.number.str);
|
||||
ast_free(p->callerid_num);
|
||||
p->callerid_num = ast_strdup(ast_channel_connected(ast)->id.number.str);
|
||||
}
|
||||
|
||||
if (ast_channel_connected(ast)->id.name.valid && ast_channel_connected(ast)->id.name.str) {
|
||||
free(p->callerid_name);
|
||||
p->callerid_name = strdup(ast_channel_connected(ast)->id.name.str);
|
||||
ast_free(p->callerid_name);
|
||||
p->callerid_name = ast_strdup(ast_channel_connected(ast)->id.name.str);
|
||||
} else if (ast_channel_connected(ast)->id.number.valid && ast_channel_connected(ast)->id.number.str) {
|
||||
free(p->callerid_name);
|
||||
p->callerid_name = strdup(ast_channel_connected(ast)->id.number.str);
|
||||
ast_free(p->callerid_name);
|
||||
p->callerid_name = ast_strdup(ast_channel_connected(ast)->id.number.str);
|
||||
} else {
|
||||
ast_channel_connected(ast)->id.name.valid = 1;
|
||||
free(ast_channel_connected(ast)->id.name.str);
|
||||
ast_channel_connected(ast)->id.name.str = strdup(gCallerID);
|
||||
free(p->callerid_name);
|
||||
p->callerid_name = strdup(ast_channel_connected(ast)->id.name.str);
|
||||
ast_free(ast_channel_connected(ast)->id.name.str);
|
||||
ast_channel_connected(ast)->id.name.str = ast_strdup(gCallerID);
|
||||
ast_free(p->callerid_name);
|
||||
p->callerid_name = ast_strdup(ast_channel_connected(ast)->id.name.str);
|
||||
}
|
||||
|
||||
/* Retrieve vars */
|
||||
@@ -992,7 +992,7 @@ static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout)
|
||||
if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323DIALEDDIGITS"))) {
|
||||
ast_copy_string(p->caller_dialedDigits, val, sizeof(p->caller_dialedDigits));
|
||||
if(!p->callerid_num)
|
||||
p->callerid_num = strdup(val);
|
||||
p->callerid_num = ast_strdup(val);
|
||||
}
|
||||
|
||||
if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323EMAIL"))) {
|
||||
@@ -1113,7 +1113,7 @@ static int ooh323_answer(struct ast_channel *ast)
|
||||
if (p) {
|
||||
|
||||
ast_mutex_lock(&p->lock);
|
||||
callToken = (p->callToken ? strdup(p->callToken) : NULL);
|
||||
callToken = (p->callToken ? ast_strdup(p->callToken) : NULL);
|
||||
if (ast_channel_state(ast) != AST_STATE_UP) {
|
||||
ast_channel_lock(ast);
|
||||
if (!p->alertsent) {
|
||||
@@ -1132,7 +1132,7 @@ static int ooh323_answer(struct ast_channel *ast)
|
||||
ooAnswerCall(p->callToken);
|
||||
}
|
||||
if (callToken) {
|
||||
free(callToken);
|
||||
ast_free(callToken);
|
||||
}
|
||||
ast_mutex_unlock(&p->lock);
|
||||
}
|
||||
@@ -1239,7 +1239,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
|
||||
if (!p) return -1;
|
||||
|
||||
ast_mutex_lock(&p->lock);
|
||||
callToken = (p->callToken ? strdup(p->callToken) : NULL);
|
||||
callToken = (p->callToken ? ast_strdup(p->callToken) : NULL);
|
||||
ast_mutex_unlock(&p->lock);
|
||||
|
||||
if (!callToken) {
|
||||
@@ -1409,7 +1409,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
|
||||
ast_verb(0, "++++ ooh323_indicate %d on %s is %d\n", condition, callToken, res);
|
||||
}
|
||||
|
||||
free(callToken);
|
||||
ast_free(callToken);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1815,25 +1815,25 @@ int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
|
||||
|
||||
|
||||
if (call->remoteDisplayName) {
|
||||
p->callerid_name = strdup(call->remoteDisplayName);
|
||||
p->callerid_name = ast_strdup(call->remoteDisplayName);
|
||||
}
|
||||
|
||||
if (ooCallGetCallingPartyNumber(call, number, OO_MAX_NUMBER_LENGTH) == OO_OK) {
|
||||
p->callerid_num = strdup(number);
|
||||
p->callerid_num = ast_strdup(number);
|
||||
}
|
||||
|
||||
if (call->remoteAliases) {
|
||||
for (alias = call->remoteAliases; alias; alias = alias->next) {
|
||||
if (alias->type == T_H225AliasAddress_h323_ID) {
|
||||
if (!p->callerid_name) {
|
||||
p->callerid_name = strdup(alias->value);
|
||||
p->callerid_name = ast_strdup(alias->value);
|
||||
}
|
||||
ast_copy_string(p->caller_h323id, alias->value, sizeof(p->caller_h323id));
|
||||
}
|
||||
else if(alias->type == T_H225AliasAddress_dialedDigits)
|
||||
{
|
||||
if(!p->callerid_num)
|
||||
p->callerid_num = strdup(alias->value);
|
||||
p->callerid_num = ast_strdup(alias->value);
|
||||
ast_copy_string(p->caller_dialedDigits, alias->value,
|
||||
sizeof(p->caller_dialedDigits));
|
||||
}
|
||||
@@ -1874,7 +1874,7 @@ int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
|
||||
user = find_user(p->callerid_name, call->remoteIP);
|
||||
if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) {
|
||||
ast_mutex_lock(&user->lock);
|
||||
p->username = strdup(user->name);
|
||||
p->username = ast_strdup(user->name);
|
||||
p->neighbor.user = user->mUseIP ? ast_strdup(user->mIP) :
|
||||
ast_strdup(user->name);
|
||||
ast_copy_string(p->context, user->context, sizeof(p->context));
|
||||
@@ -1920,7 +1920,7 @@ int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
|
||||
ast_mutex_unlock(&user->lock);
|
||||
} else {
|
||||
if (!OO_TESTFLAG(p->flags,H323_DISABLEGK)) {
|
||||
p->username = strdup(call->remoteIP);
|
||||
p->username = ast_strdup(call->remoteIP);
|
||||
p->directrtp = gDirectRTP;
|
||||
p->earlydirect = gEarlyDirect;
|
||||
} else {
|
||||
@@ -2273,7 +2273,7 @@ int onCallCleared(ooCallData *call)
|
||||
}
|
||||
ast_mutex_unlock(&userl.lock);
|
||||
|
||||
free(user);
|
||||
ast_free(user);
|
||||
}
|
||||
|
||||
if (gH323Debug)
|
||||
@@ -2305,13 +2305,13 @@ void ooh323_delete_peer(struct ooh323_peer *peer)
|
||||
}
|
||||
ast_mutex_unlock(&peerl.lock);
|
||||
|
||||
if(peer->h323id) free(peer->h323id);
|
||||
if(peer->email) free(peer->email);
|
||||
if(peer->url) free(peer->url);
|
||||
if(peer->e164) free(peer->e164);
|
||||
ast_free(peer->h323id);
|
||||
ast_free(peer->email);
|
||||
ast_free(peer->url);
|
||||
ast_free(peer->e164);
|
||||
|
||||
ao2_cleanup(peer->cap);
|
||||
free(peer);
|
||||
ao2_cleanup(peer->cap);
|
||||
ast_free(peer);
|
||||
}
|
||||
|
||||
if (gH323Debug)
|
||||
@@ -2797,8 +2797,8 @@ int reload_config(int reload)
|
||||
while (cur) {
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
free(prev->value);
|
||||
free(prev);
|
||||
ast_free(prev->value);
|
||||
ast_free(prev);
|
||||
}
|
||||
gAliasList = NULL;
|
||||
ooH323EpClearAllAliases();
|
||||
@@ -2913,7 +2913,7 @@ int reload_config(int reload)
|
||||
ast_copy_string(gCallerID, v->value, sizeof(gCallerID));
|
||||
}
|
||||
pNewAlias->type = T_H225AliasAddress_h323_ID;
|
||||
pNewAlias->value = strdup(v->value);
|
||||
pNewAlias->value = ast_strdup(v->value);
|
||||
pNewAlias->next = gAliasList;
|
||||
gAliasList = pNewAlias;
|
||||
pNewAlias = NULL;
|
||||
@@ -2934,7 +2934,7 @@ int reload_config(int reload)
|
||||
return 1;
|
||||
}
|
||||
pNewAlias->type = T_H225AliasAddress_dialedDigits;
|
||||
pNewAlias->value = strdup(v->value);
|
||||
pNewAlias->value = ast_strdup(v->value);
|
||||
pNewAlias->next = gAliasList;
|
||||
gAliasList = pNewAlias;
|
||||
pNewAlias = NULL;
|
||||
@@ -2949,7 +2949,7 @@ int reload_config(int reload)
|
||||
return 1;
|
||||
}
|
||||
pNewAlias->type = T_H225AliasAddress_email_ID;
|
||||
pNewAlias->value = strdup(v->value);
|
||||
pNewAlias->value = ast_strdup(v->value);
|
||||
pNewAlias->next = gAliasList;
|
||||
gAliasList = pNewAlias;
|
||||
pNewAlias = NULL;
|
||||
@@ -4094,22 +4094,22 @@ int ooh323_destroy(struct ooh323_pvt *p)
|
||||
}
|
||||
|
||||
if (cur->username) {
|
||||
free(cur->username);
|
||||
ast_free(cur->username);
|
||||
cur->username = 0;
|
||||
}
|
||||
|
||||
if (cur->host) {
|
||||
free(cur->host);
|
||||
ast_free(cur->host);
|
||||
cur->host = 0;
|
||||
}
|
||||
|
||||
if (cur->callerid_name) {
|
||||
free(cur->callerid_name);
|
||||
ast_free(cur->callerid_name);
|
||||
cur->callerid_name = 0;
|
||||
}
|
||||
|
||||
if (cur->callerid_num) {
|
||||
free(cur->callerid_num);
|
||||
ast_free(cur->callerid_num);
|
||||
cur->callerid_num = 0;
|
||||
}
|
||||
|
||||
@@ -4151,7 +4151,7 @@ int ooh323_destroy(struct ooh323_pvt *p)
|
||||
user->inUse--;
|
||||
ast_mutex_unlock(&user->lock);
|
||||
}
|
||||
free(cur->neighbor.user);
|
||||
ast_free(cur->neighbor.user);
|
||||
}
|
||||
} else {
|
||||
/* outgoing limit decrement here !!! */
|
||||
@@ -4181,10 +4181,10 @@ int delete_peers()
|
||||
cur = cur->next;
|
||||
|
||||
ast_mutex_destroy(&prev->lock);
|
||||
if(prev->h323id) free(prev->h323id);
|
||||
if(prev->email) free(prev->email);
|
||||
if(prev->url) free(prev->url);
|
||||
if(prev->e164) free(prev->e164);
|
||||
ast_free(prev->h323id);
|
||||
ast_free(prev->email);
|
||||
ast_free(prev->url);
|
||||
ast_free(prev->e164);
|
||||
if(prev->rtpmask) {
|
||||
ast_mutex_lock(&prev->rtpmask->lock);
|
||||
prev->rtpmask->inuse--;
|
||||
@@ -4192,10 +4192,10 @@ int delete_peers()
|
||||
if (prev->rtpmask->inuse == 0) {
|
||||
regfree(&prev->rtpmask->regex);
|
||||
ast_mutex_destroy(&prev->rtpmask->lock);
|
||||
free(prev->rtpmask);
|
||||
ast_free(prev->rtpmask);
|
||||
}
|
||||
}
|
||||
free(prev);
|
||||
ast_free(prev);
|
||||
|
||||
if (cur == peerl.peers) {
|
||||
break;
|
||||
@@ -4223,11 +4223,11 @@ int delete_users()
|
||||
if (prev->rtpmask->inuse == 0) {
|
||||
regfree(&prev->rtpmask->regex);
|
||||
ast_mutex_destroy(&prev->rtpmask->lock);
|
||||
free(prev->rtpmask);
|
||||
ast_free(prev->rtpmask);
|
||||
}
|
||||
}
|
||||
ao2_cleanup(prev->cap);
|
||||
free(prev);
|
||||
ast_free(prev);
|
||||
if (cur == userl.users) {
|
||||
break;
|
||||
}
|
||||
@@ -4339,8 +4339,8 @@ static int unload_module(void)
|
||||
while (cur) {
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
free(prev->value);
|
||||
free(prev);
|
||||
ast_free(prev->value);
|
||||
ast_free(prev);
|
||||
}
|
||||
gAliasList = NULL;
|
||||
|
||||
@@ -4504,7 +4504,7 @@ static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
|
||||
memset(&p->redirip, 0, sizeof(p->redirip));
|
||||
}
|
||||
|
||||
callToken = (p->callToken ? strdup(p->callToken) : NULL);
|
||||
callToken = (p->callToken ? ast_strdup(p->callToken) : NULL);
|
||||
|
||||
if (!callToken) {
|
||||
if (gH323Debug) {
|
||||
@@ -4532,7 +4532,7 @@ static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
|
||||
}
|
||||
|
||||
ast_mutex_unlock(&p->lock);
|
||||
free(callToken);
|
||||
ast_free(callToken);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user