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

Segfault on resolving certain NewGRF strings in specific environments #1430

Closed
DorpsGek opened this issue Nov 12, 2007 · 1 comment
Closed
Labels
component: NewGRF This issue is related to NewGRFs flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

divide opened the ticket and wrote:

I've came across a bug in which resolving a NewGRF string leads to a segfault.

To reproduce: (tested on r11418)
- download NewCargo and NewShips from http://www.ewetel.net/~michael.blunck/ttd/download.html ,
- put them on the newgrf list (NewShips first),
- set language to Polish,
- start a new game,
- use cheat to get some money,
- try to fund fishing grounds.

Openttd then segfaults when resolving "Fishing grounds" name for the news message. It seems that is because, when trying to find the gender of the name, it uses GetStringPtr() to find the string, but as table 28 is empty, this returns garbage. I'm puzzled as to why this bug doesn't manifest itself when only NewCargo (and not NewShips) is loaded; I'm also not sure that language needs to be Polish, but I think it has to be some language that checks gender of the industry name.

Anyway, as for the fix: simply replacing GetStringPtr with GetStringWithArgs fixes the problem (as GetStringWithArgs recognizes the 28 prefix of the StrID and reads the string from the proper newgrf table). This solves the segfault and provides the text needed. I've had enough hunting this bug already (that's some last three days), but it's perhaps important to find the exact reason this happens, as this could signal existence of some deeper problem with handling newgrfs.

Attachments

Reported version: trunk
Operating system: All


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

Rubidium closed the ticket.

Reason for closing: Fixed

In r11422. Thanks for the patch!


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

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

No branches or pull requests

1 participant