Utilities/Memory Viewer: Fix memory leak

This commit is contained in:
Eladash 2023-06-19 22:02:06 +03:00 committed by kd-11
parent 137f37cd41
commit 87d5f45277

View file

@ -898,9 +898,15 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
}
const auto originalBuffer = static_cast<u8*>(this->to_ptr(addr, memsize));
if (!originalBuffer)
{
return;
}
const auto convertedBuffer = new (std::nothrow) u8[memsize];
if (!originalBuffer || !convertedBuffer)
if (!convertedBuffer)
{
// OOM or invalid memory address, give up
return;