pcx: don't overflow buffer if bytes-per-line is less than image width.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 07 Feb 2018 15:43:51 -0500
changeset 5672938fc80591a
parent 566 f50c9c46ba52
child 568 c5f9cbb5d2bb
pcx: don't overflow buffer if bytes-per-line is less than image width.
IMG_pcx.c
     1.1 --- a/IMG_pcx.c	Sun Jan 28 22:10:40 2018 -0800
     1.2 +++ b/IMG_pcx.c	Wed Feb 07 15:43:51 2018 -0500
     1.3 @@ -147,7 +147,7 @@
     1.4      if (bpl > surface->pitch) {
     1.5          error = "bytes per line is too large (corrupt?)";
     1.6      }
     1.7 -    buf = (Uint8 *)SDL_malloc(bpl);
     1.8 +    buf = (Uint8 *)SDL_calloc(SDL_max(bpl, surface->pitch), 1);
     1.9      row = (Uint8 *)surface->pixels;
    1.10      for ( y=0; y<surface->h; ++y ) {
    1.11          /* decode a scan line to a temporary buffer first */