Commit 57f2f3baf397609922a6360cbcaabb13dba507d8

Philipp Wiesemann 2015-12-06T17:51:11

Windows: Added missing NULL check after SDL_stack_alloc(). SDL_stack_alloc() might wrap SDL_malloc() which can return NULL.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c
index d92a5a1..122f3d0 100644
--- a/src/video/windows/SDL_windowsframebuffer.c
+++ b/src/video/windows/SDL_windowsframebuffer.c
@@ -42,6 +42,9 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
     /* Find out the format of the screen */
     size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
     info = (LPBITMAPINFO)SDL_stack_alloc(Uint8, size);
+    if (!info) {
+        return SDL_OutOfMemory();
+    }
 
     SDL_memset(info, 0, size);
     info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);