[svn-commits] russell: branch 1.6.0 r151765 - /branches/1.6.0/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 23 11:12:01 CDT 2008


Author: russell
Date: Thu Oct 23 11:12:01 2008
New Revision: 151765

URL: http://svn.digium.com/view/asterisk?view=rev&rev=151765
Log:
Fix some memory leaks.  These issues are 1.6.0 specific.
 - Freeing the peer got accidentally removed from the peer's destructor.  It is
   still needed for astobj, but not for astobj2.
 - Fix some places that called find_user or find_peer, but did not release the
   reference that was returned.

(closes issue #13331)
Reported by: sergee
Patches:
      chan_sip-3leaks-16-r151244.diff uploaded by sergee (license 138)
Tested by: sergee

Modified:
    branches/1.6.0/channels/chan_sip.c

Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=151765&r1=151764&r2=151765
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Thu Oct 23 11:12:01 2008
@@ -3577,6 +3577,7 @@
 		ao2_ref(peer->socket.ser, -1);
 		peer->socket.ser = NULL;
 	}
+	ast_free(peer);
 }
 
 /*! \brief Update peer data in database (if used) */
@@ -19296,6 +19297,7 @@
 				struct sip_user *up = find_user(p->username, 1);
 				if (up) {
 					p->stimer->st_cached_max_se = up->stimer.st_max_se;
+					unref_user(up);
 					return (p->stimer->st_cached_max_se);
 				}
 			} 
@@ -19303,6 +19305,7 @@
 				struct sip_peer *pp = find_peer(p->peername, NULL, 1, 0);
 				if (pp) {
 					p->stimer->st_cached_max_se = pp->stimer.st_max_se;
+					unref_peer(pp);
 					return (p->stimer->st_cached_max_se);
 				}
 			}
@@ -19317,6 +19320,7 @@
 				struct sip_user *up = find_user(p->username, 1);
 				if (up) {
 					p->stimer->st_cached_min_se = up->stimer.st_min_se;
+					unref_user(up);
 					return (p->stimer->st_cached_min_se);
 				}
 			} 
@@ -19324,6 +19328,7 @@
 				struct sip_peer *pp = find_peer(p->peername, NULL, 1, 0);
 				if (pp) {
 					p->stimer->st_cached_min_se = pp->stimer.st_min_se;
+					unref_peer(pp);
 					return (p->stimer->st_cached_min_se);
 				}
 			}
@@ -19378,14 +19383,16 @@
 		struct sip_user *up = find_user(p->username, 1);
 		if (up) {
 			p->stimer->st_cached_mode = up->stimer.st_mode_oper;
-			return up->stimer.st_mode_oper;
+			unref_user(up);
+			return p->stimer->st_cached_mode;
 		}
 	} 
 	if (p->peername) {
 		struct sip_peer *pp = find_peer(p->peername, NULL, 1, 0);
 		if (pp) {
 			p->stimer->st_cached_mode = pp->stimer.st_mode_oper;
-			return pp->stimer.st_mode_oper;
+			unref_peer(pp);
+			return p->stimer->st_cached_mode;
 		}
 	}
 




More information about the svn-commits mailing list