Selaa lähdekoodia

Make sure the surface used for a software renderer is a valid format

Fixes https://github.com/libsdl-org/SDL/issues/13323
Sam Lantinga 6 päivää sitten
vanhempi
commit
ab17d66884
1 muutettua tiedostoa jossa 5 lisäystä ja 0 poistoa
  1. 5 0
      src/render/software/SDL_render_sw.c

+ 5 - 0
src/render/software/SDL_render_sw.c

@@ -1125,6 +1125,11 @@ bool SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, S
         return SDL_InvalidParamError("surface");
     }
 
+    if (SDL_BITSPERPIXEL(surface->format) < 8 ||
+        SDL_BITSPERPIXEL(surface->format) > 32) {
+        return SDL_SetError("Unsupported surface format");
+    }
+
     renderer->software = true;
 
     data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));