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

fix: segfault during crafting setup #40233

Merged

Conversation

nphyx
Copy link
Contributor

@nphyx nphyx commented May 6, 2020

Summary

SUMMARY: Bugfixes "Fixes a segfault during initializing crafts"

Purpose of change

Crafting would sometimes crash while building a list of possible liquid components for the player to chose among. Like #40227, this was related to a naive use of legacy_front that assumed the compared items would have contents and that those contents would have charges.

Describe the solution

Replaced legacy_front call with only_item in item_ptr_compare_by_charges.

Describe alternatives you've considered

Use get_item_with and filter for a contained item with charges; I couldn't get this to work in context, due to differing const expectations.

Testing

Tested using a known-bad save file from an issue report.

Additional context

The affected comparator function seems to only be used in one place. Not sure if the assumption that we're dealing with a list of liquid containers would be valid if used elsewhere; if not, this will probably cause debug messages and possible UB.

Might fix #40149 : i tested against his save file and was able to reproduce a segfault when crafting ethanol, which no longer happened after patch was applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation Fault crashes game
2 participants