res_fax: Fix reference leak caused by gateway sessions

Fax gateway session objects can be re-used, causing the
same gateway session to be added to faxregistry.container
more than once.  This change causes fax_session_new to
remove the reserved session from the container before
it's id is changed, ensuring it's possible for the
session to be freed.

ASTERISK-24392 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4049/
........

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

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@425459 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2014-10-14 16:46:06 +00:00
parent 9a7fb8ee6c
commit c0943cf8d6

View File

@@ -1216,6 +1216,7 @@ static struct ast_fax_session *fax_session_new(struct ast_fax_session_details *d
if (reserved) { if (reserved) {
s = reserved; s = reserved;
ao2_ref(reserved, +1); ao2_ref(reserved, +1);
ao2_unlink(faxregistry.container, reserved);
/* NOTE: we don't consume the reference to the reserved /* NOTE: we don't consume the reference to the reserved
* session. The session returned from fax_session_new() is a * session. The session returned from fax_session_new() is a