Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1923 - Crash with SDL_SetColorKey
Browse files Browse the repository at this point in the history
Sylvain

1/ Load an Image XPM with IMG_ReadXPMFromArray()
2/ Try to set a ColorKey on it.

I notice that :
- the SDL_Surface that is created from XPM has a palette !
- the colorkey is a RBG.

it crashes (SIGSEGV) inside the SDL_SetColorKey function:
"surface->format->palette->colors[surface->map->info.colorkey].a"
  • Loading branch information
slouken committed Jul 7, 2013
1 parent 729c67e commit 1a65483
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/video/SDL_surface.c
Expand Up @@ -175,7 +175,11 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
int flags;

if (!surface) {
return -1;
return SDL_InvalidParamError("surface");
}

if (surface->format->palette && key >= surface->format->palette->ncolors) {
return SDL_InvalidParamError("key");
}

if (flag & SDL_RLEACCEL) {
Expand Down

0 comments on commit 1a65483

Please sign in to comment.