Skip to content

Commit

Permalink
MT#55283 fix session reference booboo
Browse files Browse the repository at this point in the history
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 164f688)
  • Loading branch information
rfuchs committed Oct 2, 2024
1 parent 043eb84 commit 1fa243a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion daemon/janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1fa243a

Please sign in to comment.