[keel] Add ensureValid call to readAsset

This commit is contained in:
Gary Talent 2024-11-14 21:17:41 -06:00
parent f772e48b36
commit 6522cf8a43

View File

@ -7,6 +7,8 @@
#include <ox/claw/claw.hpp>
#include <ox/fs/fs.hpp>
#include "validation.hpp"
namespace keel {
constexpr auto K1HdrSz = 40;
@ -26,7 +28,9 @@ ox::Result<T> readAsset(ox::BufferView buff) noexcept {
if (!err) {
offset = K1HdrSz; // the size of K1 headers
}
return ox::readClaw<T>(buff + offset);
auto out = ox::readClaw<T>(buff + offset);
oxReturnError(out);
return ensureValid(out.value);
}
ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) noexcept;