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

Commit

Permalink
Fixed memory corruption with invalid pixel values.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Mar 7, 2011
1 parent ec797d2 commit 2c46199
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/video/SDL_pixels.c
Expand Up @@ -768,9 +768,13 @@ SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g,
v = (pixel & format->Bmask) >> format->Bshift;
*b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1)));
} else {
*r = format->palette->colors[pixel].r;
*g = format->palette->colors[pixel].g;
*b = format->palette->colors[pixel].b;
if (pixel < format->palette->ncolors) {
*r = format->palette->colors[pixel].r;
*g = format->palette->colors[pixel].g;
*b = format->palette->colors[pixel].b;
} else {
*r = *g = *b = 0;
}
}
}

Expand Down Expand Up @@ -802,10 +806,14 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
*a = SDL_ALPHA_OPAQUE;
}
} else {
*r = format->palette->colors[pixel].r;
*g = format->palette->colors[pixel].g;
*b = format->palette->colors[pixel].b;
*a = SDL_ALPHA_OPAQUE;
if (pixel < format->palette->ncolors) {
*r = format->palette->colors[pixel].r;
*g = format->palette->colors[pixel].g;
*b = format->palette->colors[pixel].b;
*a = SDL_ALPHA_OPAQUE;
} else {
*r = *g = *b = *a = 0;
}
}
}

Expand Down

0 comments on commit 2c46199

Please sign in to comment.