We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1923

Summary: Crash with SDL_SetColorKey
Product: SDL Reporter: Sylvain <sylvain.becker>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: small program that crashes

Description Sylvain 2013-06-20 12:34:10 UTC
I have a crash with latest SDL 2.0 trunk (2013/06/21).

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"
Comment 1 Sam Lantinga 2013-06-20 23:48:09 UTC
Thanks for the report.  Can you attach a small program that crashes?
Comment 2 Sylvain 2013-06-21 02:32:38 UTC
Created attachment 1193 [details]
small program that crashes

Here's a small program that crashes, needs SDL2 + SDL2_image

It crashes because I try to set as a colorkey, a RGB color which gets out of the bounds of the palette of the image.
Comment 3 Sam Lantinga 2013-07-06 23:30:16 UTC
Nice catch, thanks!
http://hg.libsdl.org/SDL/rev/75b8a207cb65