summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-11-01 20:11:30 -0700
committerGravatar GitHub2021-11-01 20:11:30 -0700
commitb118fa8698dbe0e2b6e663c1c37a7eac03422905 (patch)
tree14864116c00d385abba61ad2330c1c0f50e4b961 /src/core/hle/kernel/svc.cpp
parentMerge pull request #7264 from zhaobot/tx-update-20211101021628 (diff)
parentFix dangling kernel objects when exiting (diff)
downloadyuzu-b118fa8698dbe0e2b6e663c1c37a7eac03422905.tar.gz
yuzu-b118fa8698dbe0e2b6e663c1c37a7eac03422905.tar.xz
yuzu-b118fa8698dbe0e2b6e663c1c37a7eac03422905.zip
Merge pull request #7227 from vonchenplus/fix_memory_leak_v2
Fix memory leak v2
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 7f38ade1c..c43135856 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -427,11 +427,15 @@ static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr ha
427 R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles, 427 R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles,
428 num_handles), 428 num_handles),
429 ResultInvalidHandle); 429 ResultInvalidHandle);
430 for (const auto& obj : objs) {
431 kernel.RegisterInUseObject(obj);
432 }
430 } 433 }
431 434
432 // Ensure handles are closed when we're done. 435 // Ensure handles are closed when we're done.
433 SCOPE_EXIT({ 436 SCOPE_EXIT({
434 for (u64 i = 0; i < num_handles; ++i) { 437 for (u64 i = 0; i < num_handles; ++i) {
438 kernel.UnregisterInUseObject(objs[i]);
435 objs[i]->Close(); 439 objs[i]->Close();
436 } 440 }
437 }); 441 });
@@ -1561,6 +1565,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) {
1561 1565
1562 // If we succeeded, persist a reference to the thread. 1566 // If we succeeded, persist a reference to the thread.
1563 thread->Open(); 1567 thread->Open();
1568 system.Kernel().RegisterInUseObject(thread.GetPointerUnsafe());
1564 1569
1565 return ResultSuccess; 1570 return ResultSuccess;
1566} 1571}
@@ -1576,6 +1581,7 @@ static void ExitThread(Core::System& system) {
1576 auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); 1581 auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread();
1577 system.GlobalSchedulerContext().RemoveThread(current_thread); 1582 system.GlobalSchedulerContext().RemoveThread(current_thread);
1578 current_thread->Exit(); 1583 current_thread->Exit();
1584 system.Kernel().UnregisterInUseObject(current_thread);
1579} 1585}
1580 1586
1581static void ExitThread32(Core::System& system) { 1587static void ExitThread32(Core::System& system) {