Skip to content

Fix virtual POF crashes#7327

Open
BMagnu wants to merge 6 commits intoscp-fs2open:masterfrom
BMagnu:model_free_safety
Open

Fix virtual POF crashes#7327
BMagnu wants to merge 6 commits intoscp-fs2open:masterfrom
BMagnu:model_free_safety

Conversation

@BMagnu
Copy link
Copy Markdown
Member

@BMagnu BMagnu commented Mar 29, 2026

There are two memory management issues that cause crashes with virtual POFs:

  1. Loading a virtual POF that is already loaded will error out, because virtual POFs have their filename set incorrectly to the base source POF, causing cache lookup to fail and to report inconsistent model numbers.
  2. Using the same submodel multiple times as a source in the same POF causes shared data in the polymodel struct. When the polymodel deallocates, this will cause multiple frees (once for each submodel) on the shared data, causing a crash. Fixing this can either be done by deep-copying the entire submodel data (which is waaaay too much hardcoding) or by managing the polymodel data properly with smart pointers. Hence this PR refactors all dynamically allocated memory for polymodels to use shared_ptrs instead.

@BMagnu BMagnu added the fix A fix for bugs, not-a-bugs, and/or regressions. label Mar 29, 2026
@wookieejedi wookieejedi added this to the Release 25.0.1 milestone Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants