1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-21 13:39:09 +00:00

(svn r14610) -Fix [FS#2415]: possible stack corruption when reading corrupted sprites.

-Change: harden the sprite reading routine against corrupt sprites.
This commit is contained in:
rubidium
2008-11-23 13:42:05 +00:00
parent ca5ed4b2cc
commit 2277a1ff9c
3 changed files with 56 additions and 3 deletions

View File

@@ -271,7 +271,10 @@ static void* ReadSprite(SpriteCache *sc, SpriteID id, SpriteType sprite_type)
sc->type = sprite_type;
if (!sprite_loader.LoadSprite(&sprite, file_slot, file_pos, sprite_type)) return NULL;
if (!sprite_loader.LoadSprite(&sprite, file_slot, file_pos, sprite_type)) {
if (id == SPR_IMG_QUERY) usererror("Okay... something went horribly wrong. I couldn't load the fallback sprite. What should I do?");
return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL);
}
sc->ptr = BlitterFactoryBase::GetCurrentBlitter()->Encode(&sprite, &AllocSprite);
free(sprite.data);