Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in cellOskDialog #10895

Merged
merged 5 commits into from
Sep 21, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions rpcs3/Emu/Cell/Modules/cellOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
{
if (auto ccb = g_fxo->get<osk_info>().osk_confirm_callback.exchange({}))
{
vm::ptr<u16> string_to_send = vm::cast(vm::alloc(CELL_OSKDIALOG_STRING_SIZE * 2, vm::main));
std::vector<u16> string_to_send(CELL_OSKDIALOG_STRING_SIZE);
atomic_t<bool> done = false;
u32 return_value;
u32 i;
Expand All @@ -177,14 +177,16 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
if (osk->osk_text[i] == 0) break;
}

sysutil_register_cb([&, length = i](ppu_thread& cb_ppu) -> s32
sysutil_register_cb([&, length = i, string_to_send = std::move(string_to_send)](ppu_thread& cb_ppu) -> s32
{
return_value = ccb(cb_ppu, string_to_send, static_cast<s32>(length));
vm::var<u16[], vm::page_allocator<>> string_var(CELL_OSKDIALOG_STRING_SIZE, string_to_send.data());

return_value = ccb(cb_ppu, string_var.begin(), static_cast<s32>(length));
Megamouse marked this conversation as resolved.
Show resolved Hide resolved
cellOskDialog.warning("osk_confirm_callback return_value=%d", return_value);

for (u32 i = 0; i < CELL_OSKDIALOG_STRING_SIZE - 1; i++)
{
osk->osk_text[i] = string_to_send[i];
osk->osk_text[i] = string_var.begin()[i];
}

done = true;
Expand Down