Commit a688ecd6faa771f4660608dfbc636bb5fd167156

Mingjie Shen 2023-04-23T00:26:03

Check return value of SDL_malloc() (cherry picked from commit a4604cb0d616db97921a2674a63b45f3fdfb81bc)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c
index 018588d..509f029 100644
--- a/src/video/SDL_shape.c
+++ b/src/video/SDL_shape.c
@@ -138,6 +138,11 @@ static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SD
     SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree));
     SDL_Rect next = { 0, 0, 0, 0 };
 
+    if (result == NULL) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
     for (y = dimensions.y; y < dimensions.y + dimensions.h; y++) {
         for (x = dimensions.x; x < dimensions.x + dimensions.w; x++) {
             pixel_value = 0;