SDL: Fixed loading 32-bit BMP files

From 0d7edcb7032c1f5232523e0b707d7f9d831313fd Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 31 Mar 2022 16:15:51 -0700
Subject: [PATCH] Fixed loading 32-bit BMP files

---
 src/video/SDL_bmp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
index 03b3e2f48ff..cb220440a48 100644
--- a/src/video/SDL_bmp.c
+++ b/src/video/SDL_bmp.c
@@ -394,12 +394,6 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
         break;
     }
 
-    if (biBitCount >= 32) {  /* we shift biClrUsed by this value later. */
-        SDL_SetError("Unsupported or incorrect biBitCount field");
-        was_error = SDL_TRUE;
-        goto done;
-    }
-
     /* Create a compatible surface, note that the colors are RGB ordered */
     surface =
         SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
@@ -418,6 +412,12 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
             goto done;
         }
 
+        if (biBitCount >= 32) {  /* we shift biClrUsed by this value later. */
+            SDL_SetError("Unsupported or incorrect biBitCount field");
+            was_error = SDL_TRUE;
+            goto done;
+        }
+
         if (biClrUsed == 0) {
             biClrUsed = 1 << biBitCount;
         }