From d0ed54e004597639bb33a1d49fba8ef5368cb9f8 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) (cherry picked from commit 4228dc5b68ede986aadd58a94ecc844c65448e54) --- daemon/janus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon/janus.c b/daemon/janus.c index 6a18b2d07..d59f37a65 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -1462,8 +1462,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);