Fix crash in ai_manage_bay_doors from stale destroyed parent ship#7564
Merged
The-E merged 1 commit intoJul 5, 2026
Merged
Conversation
If the carrier a fighter launched from was destroyed earlier in the mission, its Ships[] entry retains stale bay door state while its object and model instance are already freed (objnum/model_instance_num == -1). When the fighter later departs, ai_manage_bay_doors would still try to animate the dead carrier's bay doors, calling model_get_instance(-1) and asserting/crashing. Co-Authored-By: Claude Sonnet 5 <[email protected]>
JohnAFernandez
approved these changes
Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ai_manage_bay_doors(code/ai/aicode.cpp) can assert/crash callingmodel_get_instance(-1)when a departing fighter's bay-door "parent" carrier was already destroyed earlier in the mission.Ships[]entry retains stale bay door state (bay_doors_status,bay_doors_wanting_open) even after itsobjectand model instance have been freed (objnum == -1,model_instance_num == -1). The existing guard only checked that a parent shipnum was assigned, not that the parent was still alive.parent_ship, return early ifparent_ship->objnum < 0 || parent_ship->model_instance_num < 0, mirroring the validity checks used elsewhere in the codebase (e.g.shiphit.cpp,object.cpp) before touching a ship's model instance.Test plan