From 269e0a02efdef404b5de5763c7707a24ac099246 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 09:33:17 -0700 Subject: [PATCH] fix(dbc): range-check JSON DBC integer fields per-cell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit val.get() throws on negative or > UINT32_MAX. The outer try-catch would then abort the entire JSON DBC load on a single bad cell. Read as int64_t, clamp to [0, UINT32_MAX], and zero out anything out of range — matches the per-field NaN scrub applied to floats one branch up. --- src/pipeline/dbc_loader.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pipeline/dbc_loader.cpp b/src/pipeline/dbc_loader.cpp index 235856eb..c839853e 100644 --- a/src/pipeline/dbc_loader.cpp +++ b/src/pipeline/dbc_loader.cpp @@ -467,7 +467,12 @@ bool DBCFile::loadJSON(const std::vector& jsonData) { if (!std::isfinite(f)) f = 0.0f; std::memcpy(&fields[col], &f, 4); } else if (val.is_number_integer()) { - fields[col] = val.get(); + // Range-check: nlohmann throws on out-of-range get + // (negative or > UINT32_MAX). Catching at the field level + // keeps a single bad cell from killing the whole DBC load. + int64_t raw = val.get(); + if (raw < 0 || raw > 0xFFFFFFFFll) raw = 0; + fields[col] = static_cast(raw); } } }