From 1fa243a2aa85912b3d70219cc1f72cf853aa351c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 1 Oct 2024 13:53:24 -0400 Subject: [PATCH] MT#55283 fix session reference booboo If we remove a session that is not the session we're looking for (re-used session ID after a removal race), we must return the incorrect session to the hash table. Change-Id: Iab73e1994251e5be766406b4e537a954b0e81f07 (cherry picked from commit 164f688fc17b439e125edb0977cc24d5f83e8ec2) --- daemon/janus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon/janus.c b/daemon/janus.c index 60eb41ce8..a6b6dd9b8 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -1465,8 +1465,11 @@ static const char *janus_destroy(struct websocket_message *wm, JsonReader *reade struct janus_session *ht_session = NULL; t_hash_table_steal_extended(janus_sessions, &session->id, NULL, &ht_session); - if (ht_session != session) + if (ht_session != session) { + if (ht_session) // return wrongly stolen session + t_hash_table_insert(janus_sessions, &ht_session->id, ht_session); return "Sesssion ID not found"; // already removed/destroyed + } janus_session_cleanup(session); obj_put(session);