src/SDL12_compat.c
changeset 79 e241008503b0
parent 78 faf3d269ede6
child 80 daac8eff8bce
     1.1 --- a/src/SDL12_compat.c	Wed Feb 20 23:56:34 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Thu Feb 21 00:04:17 2019 -0500
     1.3 @@ -1930,17 +1930,22 @@
     1.4      if (!surface12)
     1.5          goto failed;
     1.6  
     1.7 -    palette12 = (SDL12_Palette *) SDL20_malloc(sizeof (SDL12_Palette));
     1.8 -    if (!palette12)
     1.9 -        goto failed;
    1.10 +    if (surface20->format->palette) {
    1.11 +        palette12 = (SDL12_Palette *) SDL20_malloc(sizeof (SDL12_Palette));
    1.12 +        if (!palette12)
    1.13 +            goto failed;
    1.14 +    }
    1.15  
    1.16      format12 = (SDL12_PixelFormat *) SDL20_malloc(sizeof (SDL12_PixelFormat));
    1.17      if (!format12)
    1.18          goto failed;
    1.19  
    1.20 -    SDL20_zerop(palette12);
    1.21 -    palette12->ncolors = surface20->format->palette->ncolors;
    1.22 -    palette12->colors = surface20->format->palette->colors;
    1.23 +    if (palette12) {
    1.24 +        SDL20_zerop(palette12);
    1.25 +        SDL_assert(surface20->format->palette);
    1.26 +        palette12->ncolors = surface20->format->palette->ncolors;
    1.27 +        palette12->colors = surface20->format->palette->colors;
    1.28 +    }
    1.29  
    1.30      SDL20_zerop(format12);
    1.31      format12->palette = palette12;