From 9b43d91e1d0e00c9aaf69522dd6d9394118f2017 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 18:57:25 +0000 Subject: [PATCH] Bound FBX color seam staging memory --- crates/mesh/src/fbx.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/mesh/src/fbx.rs b/crates/mesh/src/fbx.rs index 64e018bb5..6c6092440 100644 --- a/crates/mesh/src/fbx.rs +++ b/crates/mesh/src/fbx.rs @@ -1124,6 +1124,16 @@ impl<'a> Build<'a, '_> { if let Some(existing) = color_indices.get(&(p, color)) { position = *existing; } else { + // Color seams need two maps as well as the output pools; do not + // grow them past the remaining file budget on hostile corner lists. + let staging = color_indices + .len() + .checked_add(1) + .and_then(|n| n.checked_mul(64)) + .and_then(|n| positions.len().checked_mul(40).and_then(|pool| n.checked_add(pool))); + if staging.is_none_or(|n| n > self.budget.left.get()) { + return Err(too_large(KIND, "color seams exceed the memory limit")); + } if first_color.insert(p, color).is_some() { pool("vertices", positions.len().saturating_add(1))?; if positions.len().saturating_add(1).checked_mul(40).is_none_or(|n| n > self.budget.left.get()) {