From c4b35488c221294d6e238c893eef1deac3a0344a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 28 Aug 2024 10:38:31 -0700
Subject: [PATCH] Fixed warning C6385: Reading invalid data from 'one_blitkey'.
---
src/video/SDL_blit_1.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/video/SDL_blit_1.c b/src/video/SDL_blit_1.c
index 0f49d67f5bc85..66a434ae2a570 100644
--- a/src/video/SDL_blit_1.c
+++ b/src/video/SDL_blit_1.c
@@ -538,8 +538,14 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
break;
case SDL_COPY_COLORKEY | SDL_COPY_BLEND: // this is not super-robust but handles a specific case we found sdl12-compat.
- return (surface->internal->map.info.a == 255) ? one_blitkey[which] :
- which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL;
+ if (surface->internal->map.info.a == 255) {
+ if (which < SDL_arraysize(one_blitkey)) {
+ return one_blitkey[which];
+ }
+ } else {
+ return which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL;
+ }
+ break;
case SDL_COPY_BLEND:
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: