From cc0e1af80fbf49cdd441da04b7d035d949c331e6 Mon Sep 17 00:00:00 2001 From: rosenkolev1 <50500415+rosenkolev1@users.noreply.github.com> Date: Thu, 19 Mar 2026 23:25:54 +0200 Subject: [PATCH] Fix tls leak for non-primary thread --- src/core/libraries/kernel/threads/tcb.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/kernel/threads/tcb.cpp b/src/core/libraries/kernel/threads/tcb.cpp index 043d11e4e..c30db6fea 100644 --- a/src/core/libraries/kernel/threads/tcb.cpp +++ b/src/core/libraries/kernel/threads/tcb.cpp @@ -68,7 +68,7 @@ void TcbDtor(Core::Tcb* oldtls) { ASSERT_MSG(num_dtvs <= max_tls_index, "Out of bounds DTV access"); const u32 static_tls_size = linker->StaticTlsSize(); - const u8* tls_base = (const u8*)oldtls - static_tls_size; + u8* tls_base = (u8*)oldtls - static_tls_size; for (int i = 1; i < num_dtvs; i++) { u8* dtv_ptr = dtv_table[i + 1].pointer; @@ -76,8 +76,9 @@ void TcbDtor(Core::Tcb* oldtls) { linker->FreeTlsForNonPrimaryThread(dtv_ptr); } } - delete[] dtv_table; + + linker->FreeTlsForNonPrimaryThread(tls_base); } struct TlsIndex {