Fixed crash in RLE colorkey blitting
Fixes Maelstrom running over sdl2-compat with SDL3
This commit is contained in:
@@ -1064,7 +1064,7 @@ static bool RLEAlphaSurface(SDL_Surface *surface)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// save the destination format so we can undo the encoding later
|
// save the destination format so we can undo the encoding later
|
||||||
*(SDL_PixelFormat *)rlebuf = df->format;
|
*(SDL_PixelFormat *)rlebuf = dest->format;
|
||||||
dst = rlebuf + sizeof(SDL_PixelFormat);
|
dst = rlebuf + sizeof(SDL_PixelFormat);
|
||||||
|
|
||||||
// Do the actual encoding
|
// Do the actual encoding
|
||||||
@@ -1232,6 +1232,7 @@ static const getpix_func getpixes[4] = {
|
|||||||
|
|
||||||
static bool RLEColorkeySurface(SDL_Surface *surface)
|
static bool RLEColorkeySurface(SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
|
SDL_Surface *dest;
|
||||||
Uint8 *rlebuf, *dst;
|
Uint8 *rlebuf, *dst;
|
||||||
int maxn;
|
int maxn;
|
||||||
int y;
|
int y;
|
||||||
@@ -1242,6 +1243,11 @@ static bool RLEColorkeySurface(SDL_Surface *surface)
|
|||||||
Uint32 ckey, rgbmask;
|
Uint32 ckey, rgbmask;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
|
dest = surface->map.info.dst_surface;
|
||||||
|
if (!dest) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// calculate the worst case size for the compressed surface
|
// calculate the worst case size for the compressed surface
|
||||||
switch (bpp) {
|
switch (bpp) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -1263,15 +1269,18 @@ static bool RLEColorkeySurface(SDL_Surface *surface)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxsize += sizeof(SDL_PixelFormat);
|
||||||
rlebuf = (Uint8 *)SDL_malloc(maxsize);
|
rlebuf = (Uint8 *)SDL_malloc(maxsize);
|
||||||
if (!rlebuf) {
|
if (!rlebuf) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// save the destination format so we can undo the encoding later
|
||||||
|
*(SDL_PixelFormat *)rlebuf = dest->format;
|
||||||
|
|
||||||
// Set up the conversion
|
// Set up the conversion
|
||||||
srcbuf = (Uint8 *)surface->pixels;
|
srcbuf = (Uint8 *)surface->pixels;
|
||||||
maxn = bpp == 4 ? 65535 : 255;
|
maxn = bpp == 4 ? 65535 : 255;
|
||||||
dst = rlebuf;
|
dst = rlebuf + sizeof(SDL_PixelFormat);
|
||||||
rgbmask = ~surface->fmt->Amask;
|
rgbmask = ~surface->fmt->Amask;
|
||||||
ckey = surface->map.info.colorkey & rgbmask;
|
ckey = surface->map.info.colorkey & rgbmask;
|
||||||
lastline = dst;
|
lastline = dst;
|
||||||
|
|||||||
Reference in New Issue
Block a user