Skip to content

Commit f676999

Browse files
committed
pcx: don't overflow buffer if bytes-per-line is less than image width.
1 parent 62cd8cd commit f676999

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

IMG_pcx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
147147
if (bpl > surface->pitch) {
148148
error = "bytes per line is too large (corrupt?)";
149149
}
150-
buf = (Uint8 *)SDL_malloc(bpl);
150+
buf = (Uint8 *)SDL_calloc(SDL_max(bpl, surface->pitch), 1);
151151
row = (Uint8 *)surface->pixels;
152152
for ( y=0; y<surface->h; ++y ) {
153153
/* decode a scan line to a temporary buffer first */

0 commit comments

Comments
 (0)