aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-04 20:36:16 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-04 20:36:16 +0000
commitde7843bf7102790358c6dc05ed6e7c70250c342d (patch)
tree52202c559c909d3399b23587958cb5a50eed388f
parent737272b1c0060527355ee2c0116acc465592662c (diff)
Fix some bugs in the SIP tcp helper thread.
- fix a spot where a lock wouldn't get unlocked in an error condition - call ast_mutex_destroy() on the lock before freeing its memory (related to issue #11972) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@105734 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f5cbda2b5..8b017eb30 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2200,8 +2200,10 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct server_instance
while (req.len < 4 || strncmp((char *)&req.data + req.len - 4, "\r\n\r\n", 4)) {
if (req.socket.lock)
ast_mutex_lock(req.socket.lock);
- if (!fgets(buf, sizeof(buf), ser->f))
+ if (!fgets(buf, sizeof(buf), ser->f)) {
+ ast_mutex_unlock(req.socket.lock);
goto cleanup;
+ }
if (req.socket.lock)
ast_mutex_unlock(req.socket.lock);
if (me->stop)
@@ -2237,7 +2239,12 @@ cleanup:
cleanup2:
fclose(ser->f);
ast_free(ser);
- ast_free(req.socket.lock);
+
+ if (req.socket.lock) {
+ ast_mutex_destroy(req.socket.lock);
+ ast_free(req.socket.lock);
+ req.socket.lock = NULL;
+ }
return NULL;
}