mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
fix(dbc): range-check JSON DBC integer fields per-cell
val.get<uint32_t>() 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.
This commit is contained in:
parent
64b85ff9ff
commit
269e0a02ef
1 changed files with 6 additions and 1 deletions
|
|
@ -467,7 +467,12 @@ bool DBCFile::loadJSON(const std::vector<uint8_t>& jsonData) {
|
|||
if (!std::isfinite(f)) f = 0.0f;
|
||||
std::memcpy(&fields[col], &f, 4);
|
||||
} else if (val.is_number_integer()) {
|
||||
fields[col] = val.get<uint32_t>();
|
||||
// Range-check: nlohmann throws on out-of-range get<uint32_t>
|
||||
// (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<int64_t>();
|
||||
if (raw < 0 || raw > 0xFFFFFFFFll) raw = 0;
|
||||
fields[col] = static_cast<uint32_t>(raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue