From b85734e3110fa1617650af98f9c10951681df339 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 09:15:02 -0700 Subject: [PATCH] fix(wom): cap WOM3 batch count at load limit (4096) on save Same per-section cap pattern. The loader caps batchCount at 4096; save iterated all validBatches without checking. A model with >4096 batches would write a header rejected on round-trip. --- src/pipeline/wowee_model.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pipeline/wowee_model.cpp b/src/pipeline/wowee_model.cpp index a609a946..f365809f 100644 --- a/src/pipeline/wowee_model.cpp +++ b/src/pipeline/wowee_model.cpp @@ -395,9 +395,14 @@ bool WoweeModelLoader::save(const WoweeModel& model, const std::string& basePath if (totalTex > 0 && b.textureIndex >= totalTex) continue; validBatches.push_back(b); } - uint32_t batchCount = static_cast(validBatches.size()); + // Cap batches at the load limit (4096). validBatches has already + // dropped invalid entries; this trims the head if the model has + // more than the loader will accept. + uint32_t batchCount = static_cast( + std::min(validBatches.size(), 4096)); f.write(reinterpret_cast(&batchCount), 4); - for (const auto& b : validBatches) { + for (uint32_t bi = 0; bi < batchCount; bi++) { + const auto& b = validBatches[bi]; f.write(reinterpret_cast(&b.indexStart), 4); f.write(reinterpret_cast(&b.indexCount), 4); f.write(reinterpret_cast(&b.textureIndex), 4);