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

Commit

Permalink
Fixed bug 1534 - SIGSEGV in SDL_ConvertSurface() for certain formats …
Browse files Browse the repository at this point in the history
…in SDL2

Don't assume that 8 bit formats are indexed.
Thanks to Gabriel Jacobo for research and potential patches.
  • Loading branch information
slouken committed May 22, 2013
1 parent 1adbfb4 commit 786e80a
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 229 deletions.
15 changes: 11 additions & 4 deletions src/video/SDL_blit.c
Expand Up @@ -239,9 +239,11 @@ SDL_CalculateBlit(SDL_Surface * surface)
/* Choose a standard blit function */
if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) {
blit = SDL_BlitCopy;
} else if (surface->format->BitsPerPixel < 8) {
} else if (surface->format->BitsPerPixel < 8 &&
SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
blit = SDL_CalculateBlit0(surface);
} else if (surface->format->BytesPerPixel == 1) {
} else if (surface->format->BytesPerPixel == 1 &&
SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
blit = SDL_CalculateBlit1(surface);
} else if (map->info.flags & SDL_COPY_BLEND) {
blit = SDL_CalculateBlitA(surface);
Expand All @@ -260,8 +262,13 @@ SDL_CalculateBlit(SDL_Surface * surface)
if (blit == NULL)
#endif
{
if (surface->format->BytesPerPixel > 1
&& dst->format->BytesPerPixel > 1) {
Uint32 src_format = surface->format->format;
Uint32 dst_format = dst->format->format;

if (!SDL_ISPIXELFORMAT_INDEXED(src_format) &&
!SDL_ISPIXELFORMAT_FOURCC(src_format) &&
!SDL_ISPIXELFORMAT_INDEXED(dst_format) &&
!SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
blit = SDL_Blit_Slow;
}
}
Expand Down

0 comments on commit 786e80a

Please sign in to comment.