chan_sip.c: Fixed off-nominal message iterator ref count and alloc fail issues.

* Fixed early exit in sip_msg_send() not destroying the message iterator.

* Made ast_msg_var_iterator_next() and ast_msg_var_iterator_destroy()
tolerant of a NULL iter parameter in case ast_msg_var_iterator_init()
fails.

* Made ast_msg_var_iterator_destroy() clean up any current message data
ref.

* Made struct ast_msg_var_iterator, ast_msg_var_iterator_init(),
ast_msg_var_iterator_next(), ast_msg_var_unref_current(), and
ast_msg_var_iterator_destroy() use iter instead of i.

* Eliminated RAII_VAR usage in res_pjsip_messaging.c:vars_to_headers().
........

Merged revisions 413139 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@413142 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2014-04-30 20:47:24 +00:00
parent d7956cdb83
commit a136fc1cae
4 changed files with 41 additions and 29 deletions

View File

@@ -26923,12 +26923,11 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f
return -1;
}
for (iter = ast_msg_var_iterator_init(msg);
ast_msg_var_iterator_next(msg, iter, &var, &val);
ast_msg_var_unref_current(iter)) {
for (iter = ast_msg_var_iterator_init(msg);
ast_msg_var_iterator_next(msg, iter, &var, &val);
ast_msg_var_unref_current(iter)) {
if (!strcasecmp(var, "Request-URI")) {
ast_string_field_set(pvt, fullcontact, val);
ast_msg_var_unref_current(iter);
break;
}
}
@@ -27013,6 +27012,7 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f
if (!strcasecmp(var, "Max-Forwards")) {
/* Decrement Max-Forwards for SIP loop prevention. */
if (sscanf(val, "%30d", &pvt->maxforwards) != 1 || pvt->maxforwards < 1) {
ast_msg_var_iterator_destroy(iter);
sip_pvt_unlock(pvt);
dialog_unlink_all(pvt);
dialog_unref(pvt, "MESSAGE(Max-Forwards) reached zero.");