From 3eeee794e586a819e0e6b9c5eae628a3e34e530f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Oct 2023 22:41:36 +0200 Subject: [PATCH] use a TArray for the screenshot buffer. --- source/core/rendering/hw_entrypoint.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index d4ca14aec..0d450d9bb 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -283,11 +283,10 @@ void RenderToSavePic(FRenderViewpoint& vp, FileWriter* file, int width, int heig int numpixels = width * height; - uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3); - screen->CopyScreenToBuffer(width, height, scr); + TArray scr(numpixels * 3, true); + screen->CopyScreenToBuffer(width, height, scr.Data()); - DoWriteSavePic(file, scr, width, height, screen->FlipSavePic()); - M_Free(scr); + DoWriteSavePic(file, scr.Data(), width, height, screen->FlipSavePic()); // Switch back the screen render buffers screen->SetViewportRects(nullptr);