Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reallocation of sprite cache may lead to crash (fix included) #1717

Closed
DorpsGek opened this issue Jan 28, 2008 · 1 comment
Closed

Reallocation of sprite cache may lead to crash (fix included) #1717

DorpsGek opened this issue Jan 28, 2008 · 1 comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

PhilSophus opened the ticket and wrote:

In this topic, Swallow reported a crash during startup of OpenTTD: http://www.tt-forums.net/viewtopic.php?f=31&t=35984

I found out, that this is probably due to an error in DupSprite() in spritecache.cpp:
void DupSprite(SpriteID old_spr, SpriteID new_spr)
{
SpriteCache *scold = GetSpriteCache(old_spr);
SpriteCache *scnew = AllocateSpriteCache(new_spr);
...
}

The call to AllocateSpriteCache may reallocate the _spritecache array letting scold point to invalid memory. Swapping these two lines should solve the issue (see attached patch). This seems to be the only place in the code, that has this problem.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/1717
@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r12005.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1717

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant