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
........

Merged revisions 413142 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413144 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2014-04-30 21:03:29 +00:00
parent f2a060f502
commit 20750e261b
4 changed files with 41 additions and 29 deletions

View File

@@ -246,25 +246,25 @@ struct ast_msg_var_iterator *ast_msg_var_iterator_init(const struct ast_msg *msg
/*!
* \brief Get the next variable name and value that is set for sending outbound
* \param msg The message with the variables
* \param i An iterator created with ast_msg_var_iterator_init
* \param iter An iterator created with ast_msg_var_iterator_init
* \param name A pointer to the name result pointer
* \param value A pointer to the value result pointer
*
* \retval 0 No more entries
* \retval 1 Valid entry
*/
int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iterator *i, const char **name, const char **value);
int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value);
/*!
* \brief Destroy a message variable iterator
* \param i Iterator to be destroyed
* \param iter Iterator to be destroyed
*/
void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *i);
void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *iter);
/*!
* \brief Unref a message var from inside an iterator loop
*/
void ast_msg_var_unref_current(struct ast_msg_var_iterator *i);
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter);
#if defined(__cplusplus) || defined(c_plusplus)
}