From: Sam Lantinga <slouken@libsdl.org>
Date: Tue, 30 Nov 2021 10:23:21 -0800
Subject: Fixed potential buffer overflow in YUV conversion

Bug: https://github.com/libsdl-org/SDL/issues/5043
Origin: upstream, 2.0.20, commit:8589134f160a9d0898a2f3bdf87300837be4367d
---
 src/video/yuv2rgb/yuv_rgb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/video/yuv2rgb/yuv_rgb.c b/src/video/yuv2rgb/yuv_rgb.c
index 6e821a8..7908b8c 100644
--- a/src/video/yuv2rgb/yuv_rgb.c
+++ b/src/video/yuv2rgb/yuv_rgb.c
@@ -91,7 +91,7 @@ static uint8_t clampU8(int32_t v)
 	255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 	255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
 	};
-	return lut[(v+128*PRECISION_FACTOR)>>PRECISION];
+	return lut[((v+128*PRECISION_FACTOR)>>PRECISION)&511];
 }
 
 
