From a7f2ec6a5e85d5a11e4c1a68409710ce5f07616f Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 Apr 2020 19:53:33 +0100 Subject: [PATCH] Safely-handle LockSurface failing Fixes crash on Wii U at 1280x720 (LockSurface fails there because CreateSurface fails - maybe it's running out of memory again) --- src/Draw.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Draw.cpp b/src/Draw.cpp index 31792511..ce2175e8 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -154,6 +154,9 @@ static BOOL ScaleAndUploadSurface(const unsigned char *image_buffer, int width, unsigned int pitch; unsigned char *pixels = RenderBackend_LockSurface(surf[surf_no], &pitch, width * magnification, height * magnification); + if (pixels == NULL) + return FALSE; + if (magnification == 1) { // Just copy the pixels the way they are