From 49225f5f0429da80e9fbed49fd705cda399a2da7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 31 Dec 2016 18:11:19 -0800 Subject: [PATCH] We don't currently support blitting to < 8 bpp surfaces, return an error instead of corrupting memory in that case. --- src/video/SDL_blit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 90aa87898..b64f4cbf4 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -219,6 +219,12 @@ SDL_CalculateBlit(SDL_Surface * surface) SDL_BlitMap *map = surface->map; SDL_Surface *dst = map->dst; + /* We don't currently support blitting to < 8 bpp surfaces */ + if (dst->format->BitsPerPixel < 8) { + SDL_InvalidateMap(map); + return SDL_SetError("Blit combination not supported"); + } + /* Clean everything out to start */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { SDL_UnRLESurface(surface, 1);