diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-10-23 16:12:01 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-10-23 16:12:01 +0000 |
commit | 6da211a8b5c03e6a4741ba033e221c0bf2c06391 (patch) | |
tree | 3ba2b617ba7422f34e564b775e5d31cdf713dc9c | |
parent | 8e685c6160cf81faf113a38d9166a1c9a9c93967 (diff) |
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
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@151765 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index fad808cc2..c3d9f7a8b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3577,6 +3577,7 @@ static void sip_destroy_peer(struct sip_peer *peer) 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 @@ int st_get_se(struct sip_pvt *p, int max) 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 @@ int st_get_se(struct sip_pvt *p, int max) 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 @@ int st_get_se(struct sip_pvt *p, int max) 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 @@ int st_get_se(struct sip_pvt *p, int max) 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 @@ enum st_mode st_get_mode(struct sip_pvt *p) 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; } } |