Skip to content
Snippets Groups Projects
Commit a1371209 authored by Olivier Dion's avatar Olivier Dion Committed by Sébastien Blin
Browse files

contrib/pjproject: Fix another socket leak

Change-Id: I8c834ea5abefc1f61996ab5098f1d7caf74e36dc
parent 97964808
Branches
Tags
No related merge requests found
From a9b3b09128d1e96cfa4a8ccc74d406c5bf1895db Mon Sep 17 00:00:00 2001 From c1093eeb18a4090fd7eac6e8e70a6da1777f0907 Mon Sep 17 00:00:00 2001
From: Olivier Dion <olivier.dion@savoirfairelinux.com> From: Olivier Dion <olivier.dion@savoirfairelinux.com>
Date: Mon, 19 Jul 2021 16:49:28 -0400 Date: Mon, 26 Jul 2021 09:52:50 -0400
Subject: [PATCH] pjnath/turn_sock: Fix leak of socket Subject: [PATCH] pjnath/turn_sock: Fix leak of socket
Opened socket is not closed on binding and quality of service error. The socket Opened socket is not closed on binding and quality of service error. The socket
is owned by the active sock only if everything went well. is owned by the active sock only if everything went well.
--- ---
pjnath/src/pjnath/turn_sock.c | 2 ++ pjnath/src/pjnath/turn_sock.c | 7 +++++++
1 file changed, 2 insertions(+) 1 file changed, 7 insertions(+)
diff --git a/pjnath/src/pjnath/turn_sock.c b/pjnath/src/pjnath/turn_sock.c diff --git a/pjnath/src/pjnath/turn_sock.c b/pjnath/src/pjnath/turn_sock.c
index dc6304d9f..b41e32220 100644 index dc6304d9f..a453f5b65 100644
--- a/pjnath/src/pjnath/turn_sock.c --- a/pjnath/src/pjnath/turn_sock.c
+++ b/pjnath/src/pjnath/turn_sock.c +++ b/pjnath/src/pjnath/turn_sock.c
@@ -1195,6 +1195,7 @@ static void turn_on_state(pj_turn_session *sess, @@ -1195,6 +1195,7 @@ static void turn_on_state(pj_turn_session *sess,
...@@ -29,6 +29,17 @@ index dc6304d9f..b41e32220 100644 ...@@ -29,6 +29,17 @@ index dc6304d9f..b41e32220 100644
pj_turn_sock_destroy(turn_sock); pj_turn_sock_destroy(turn_sock);
return; return;
} }
@@ -1262,6 +1264,11 @@ static void turn_on_state(pj_turn_session *sess,
turn_sock->cfg.ioqueue, &asock_cb,
turn_sock,
&turn_sock->active_sock);
+
+ /* Active socket failed to take ownership of `sock` */
+ if (status != PJ_SUCCESS) {
+ pj_sock_close(sock);
+ }
}
#if PJ_HAS_SSL_SOCK
else {
-- --
2.32.0 2.32.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment