From 4b3c530dd177efaaa27b3045435a5925a5100222 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 31 Jan 2024 09:55:52 -0800 Subject: [PATCH] Fixed out of bounds access This can happen if we try to blit from a surface with an unknown pixel format --- src/video/SDL_blit_N.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 54dc67092..f99f8c253 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -3374,7 +3374,8 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) if (dstfmt->Amask) { a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA; } - if (srcfmt->BytesPerPixel <= SDL_arraysize(normal_blit)) { + if (srcfmt->BytesPerPixel > 0 && + srcfmt->BytesPerPixel <= SDL_arraysize(normal_blit)) { table = normal_blit[srcfmt->BytesPerPixel - 1]; for (which = 0; table[which].dstbpp; ++which) { if (MASKOK(srcfmt->Rmask, table[which].srcR) &&