Skip to content

Commit

Permalink
SDL_FillRects: prevent empty SDL_surface from raising an error message
Browse files Browse the repository at this point in the history
It's legitimate to have a surface with 0 width or height (null 'pixels' pointer).
But calling SDL_FillRects would wrongly set the error "You must lock the surface".
  • Loading branch information
1bsyl committed Nov 27, 2020
1 parent 3fbff2a commit 2c079a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/video/SDL_fillrect.c
Expand Up @@ -314,6 +314,11 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
return SDL_SetError("SDL_FillRect(): Unsupported surface format");
}

/* Nothing to do */
if (dst->w == 0 || dst->h == 0) {
return 0;
}

/* Perform software fill */
if (!dst->pixels) {
return SDL_SetError("SDL_FillRect(): You must lock the surface");
Expand Down

0 comments on commit 2c079a2

Please sign in to comment.