-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Prevent crashes when an iuse doesn't exist. #39849
Conversation
Legacy use actions (e.g.
But modern use actions (e.g.
|
I'll look at those too, I thought they were handled better. |
f509e65
to
f17268a
Compare
So there's a tradeoff, if usage_from_object() doesn't throw an exception in this situation, we don't get as good of an error message when it fails, but I prefer the robustness for this situation. |
Is it worth throwing an error in |
Fantastic idea. |
f17268a
to
cd5cdd1
Compare
Summary
SUMMARY: None
Purpose of change
The recent removal of the ROYAL_JELLY iuse in #39782 triggered breakage in downstream mods that invoked it.
See https://discourse.cataclysmdda.org/t/segmentation-fault-on-finalizing-items/23367
The root cause is that the code handling iuse function lookup and assignment to itypes was generating a null "use_function" object, but was then not checking it for null before assigning it to the iuse, and it would inevitably be invoked during finalization, causing a crash.
Describe the solution
Adds a wrapper around iuse function lookup and assignment that refrains from emplacing the use_function if it is null. The lookup function already reports the failed lookup, so no further diagnostics are needed.
Describe alternatives you've considered
I considered trying to make the returned null object capable of being dereferenced, but that seems like a bandaid type fix that might be fragile in the future, and refraining from emplacing the function object is more robust.
Testing
Create an item that specifies a non-existent iuse id and load it.
It should display a debug message but continue to load.