diff options
| author | 2021-10-25 18:55:20 +0800 | |
|---|---|---|
| committer | 2021-10-27 09:06:22 +0800 | |
| commit | a8b01049235bffa13d18a010311c16c8b9c316b4 (patch) | |
| tree | 3e8f433c3da629b09a4b3e000047ceb6f8ac3ec0 /src/core/hle/kernel/svc.cpp | |
| parent | Merge pull request #7218 from bylaws/aswdqdsam (diff) | |
| download | yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.gz yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.xz yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.zip | |
Fix memory leak
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index f98f24a60..d30755b7e 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 | }); |
| @@ -1544,6 +1548,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1544 | 1548 | ||
| 1545 | // If we succeeded, persist a reference to the thread. | 1549 | // If we succeeded, persist a reference to the thread. |
| 1546 | thread->Open(); | 1550 | thread->Open(); |
| 1551 | system.Kernel().RegisterInUseObject(thread.GetPointerUnsafe()); | ||
| 1547 | 1552 | ||
| 1548 | return ResultSuccess; | 1553 | return ResultSuccess; |
| 1549 | } | 1554 | } |
| @@ -1559,6 +1564,7 @@ static void ExitThread(Core::System& system) { | |||
| 1559 | auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); | 1564 | auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); |
| 1560 | system.GlobalSchedulerContext().RemoveThread(current_thread); | 1565 | system.GlobalSchedulerContext().RemoveThread(current_thread); |
| 1561 | current_thread->Exit(); | 1566 | current_thread->Exit(); |
| 1567 | system.Kernel().UnregisterInUseObject(current_thread); | ||
| 1562 | } | 1568 | } |
| 1563 | 1569 | ||
| 1564 | static void ExitThread32(Core::System& system) { | 1570 | static void ExitThread32(Core::System& system) { |