aboutsummaryrefslogtreecommitdiffstats
path: root/main/sdl2_image/CVE-2018-3838.patch
blob: bdc673de3c6953d46e0abee946e49e19eb368795 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/IMG_xcf.c b/IMG_xcf.c
index edce5f8..d759633 100644
--- a/IMG_xcf.c
+++ b/IMG_xcf.c
@@ -474,6 +474,10 @@ static unsigned char * load_xcf_tile_rle (SDL_RWops * src, Uint32 len, int bpp,
   int i, size, count, j, length;
   unsigned char val;
 
+  if (len == 0) {  /* probably bogus data. */
+    return NULL;
+  }
+
   t = load = (unsigned char *) SDL_malloc (len);
   reallen = SDL_RWread (src, t, 1, len);
 
@@ -607,6 +611,16 @@ static int do_layer_surface (SDL_Surface * surface, SDL_RWops * src, xcf_header
        ox, oy);
       }
 
+      if (!tile) {
+          if (hierarchy) {
+              free_xcf_hierarchy(hierarchy);
+          }
+          if (level) {
+              free_xcf_level(level);
+          }
+          return 1;
+      }
+
       p8  = tile;
       p16 = (Uint16 *) p8;
       p   = (Uint32 *) p8;