diff --git a/src/bgdl.cpp b/src/bgdl.cpp index d78da892..1be121c2 100644 --- a/src/bgdl.cpp +++ b/src/bgdl.cpp @@ -214,11 +214,12 @@ void scedownload_start_with_rif( params.init.unk_3 = 0; params.init.sizeDC0 = 0xDC0; - params.init.addr_DC0 = - (ipmi_download_param*)new char[params.init.sizeDC0](); + std::vector buf_dc0(params.init.sizeDC0); + params.init.addr_DC0 = (ipmi_download_param*)buf_dc0.data(); params.size2E0 = 0x2E0; - params.addr_2E0 = new char[params.size2E0]; + std::vector buf_2e0(params.size2E0); + params.addr_2E0 = buf_2e0.data(); params.pBgdlId = (uint32_t*)&bgdlid; // points to -1 params.unk_5 = 4; @@ -251,6 +252,10 @@ void scedownload_start_with_rif( throw formatEx( "SceDownload change_state bgdlid failed: {:#08x}", static_cast(res)); + if (reinterpret_cast(params.init.addr_DC0) < 0) + throw formatEx( + "SceDownload change_state DC0 failed: {:#08x}", + reinterpret_cast(params.init.addr_DC0)); result = 0; @@ -270,9 +275,8 @@ void scedownload_start_with_rif( throw formatEx( "SceDownload second change_state result failed: {:#08x}", static_cast(result)); - - delete[] reinterpret_cast(params.init.addr_DC0); - delete[] static_cast(params.addr_2E0); + buf_dc0.clear(); + buf_2e0.clear(); } std::unique_ptr new_scedownload()