Base: Coverity cleanup

This commit is contained in:
Chris Hennes
2025-03-02 21:16:01 -06:00
committed by Benjamin Nauck
parent f3bb974855
commit d850e87567
2 changed files with 6 additions and 3 deletions

View File

@@ -653,8 +653,11 @@ void ComplexGeoData::RestoreDocFile(Base::Reader& reader)
return;
}
}
std::size_t count = atoi(marker.c_str());
restoreStream(reader, count);
auto count = atoll(marker.c_str()); // Try to prevent UB if the number is unreasonably large
if (count < 0 || count > std::numeric_limits<int>::max()) {
FC_THROWM(Base::RuntimeError, "Failed to restore element map " << _persistenceName);
}
restoreStream(reader, static_cast<std::size_t>(count));
}
unsigned int ComplexGeoData::getMemSize() const