From 79a190aa23cb6626e2a6844a6c2a31fb9a21f923 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 7 Aug 2023 22:20:40 -0700 Subject: [PATCH] Fixed setting invalid bpp for FOURCC formats in SDL_GetMasksForPixelFormatEnum() --- src/video/SDL_pixels.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index acf21cca0a..7c31a24b4f 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -140,6 +140,12 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(Uint32 format, int *bpp, Uint32 *Rmask, #if SDL_HAVE_YUV /* Partial support for SDL_Surface with FOURCC */ + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + /* Not a format that uses masks */ + *bpp = 0; + *Rmask = *Gmask = *Bmask = *Amask = 0; + return SDL_TRUE; + } #else if (SDL_ISPIXELFORMAT_FOURCC(format)) { SDL_SetError("SDL not built with YUV support"); @@ -181,11 +187,6 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(Uint32 format, int *bpp, Uint32 *Rmask, return SDL_TRUE; } - if (SDL_ISPIXELFORMAT_FOURCC(format)) { - /* Not a format that uses masks */ - return SDL_TRUE; - } - if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 && SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 && SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) {