fix(htree): Reject invalid W3D hierarchy pivot counts - #3195
Conversation
Prevent the synthetic-root increment from wrapping to zero so load does not skip allocation and then write Pivot[0]. Co-authored-by: Cursor <cursoragent@cursor.com>
PR Summary by QodoReject overflowing pre-3.0 W3D hierarchy pivot counts
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can switch off images and animations for a plain-text comment |
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/htree.cpp | Validates the adjusted hierarchy pivot count before allocating and reading pivots, preventing the malformed pre-3.0 null-write path. |
Reviews (2): Last reviewed commit: "style(htree): Remove redundant validatio..." | Re-trigger Greptile
|
The change title and description are outdated. |
|
updated |
HTreeClass::Load_W3Dexpects every loaded hierarchy to contain at least one pivot because later code accessesPivot[0].Previously, a count of zero skipped allocation but allowed loading to continue. Malformed pre-3.0 files could also reach that state by setting
NumPivotstoUINT32_MAX, which wraps to zero when the loader adds the synthetic root pivot.This change validates the adjusted pivot count before allocation. Counts below one now return
LOAD_ERROR, while valid hierarchies follow the existing allocation and loading path.This prevents corrupt or crafted W3D assets from leaving an
HTreeClasswith no pivot storage and crashing whenPivot[0]is used.Found by clang-tidy.