From: Russell Bryant Date: Tue, 14 Aug 2007 17:33:12 +0000 (+0000) Subject: Merged revisions 79436 via svnmerge from X-Git-Tag: 1.6.0-beta1~3^2~1729 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e038cdc7c429bebb4a991474e6c40829d24ca5b;p=thirdparty%2Fasterisk.git Merged revisions 79436 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r79436 | russell | 2007-08-14 12:31:39 -0500 (Tue, 14 Aug 2007) | 3 lines Fix some memory leaks throughout chan_iax2 related to the use of realtime. I found these while working on iax2_peer object reference tracking. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@79437 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 48a40e98f6..164b217a92 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -6015,8 +6015,11 @@ static int update_registry(struct sockaddr_in *sin, int callno, char *devtype, i return -1; } ast_mutex_lock(&iaxsl[callno]); - if (!iaxs[callno]) + if (!iaxs[callno]) { + if (ast_test_flag(p, IAX_TEMPONLY)) + destroy_peer(p); return -1; + } if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS))) { if (sin->sin_addr.s_addr) { @@ -6054,8 +6057,11 @@ static int update_registry(struct sockaddr_in *sin, int callno, char *devtype, i } /* Make sure our call still exists, an INVAL at the right point may make it go away */ - if (!iaxs[callno]) + if (!iaxs[callno]) { + if (ast_test_flag(p, IAX_TEMPONLY)) + destroy_peer(p); return 0; + } /* Store socket fd */ p->sockfd = fd; @@ -6140,8 +6146,11 @@ static int registry_authrequest(int callno) ast_mutex_unlock(&iaxsl[callno]); p = find_peer(peer_name, 1); ast_mutex_lock(&iaxsl[callno]); - if (!iaxs[callno]) + if (!iaxs[callno]) { + if (p && ast_test_flag(p, IAX_TEMPONLY)) + destroy_peer(p); return -1; + } if (p) { memset(&ied, 0, sizeof(ied)); iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods); @@ -10551,6 +10560,9 @@ static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *dat } } + if (ast_test_flag(peer, IAX_TEMPONLY)) + destroy_peer(peer); + return 0; }