diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-29 13:55:38 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-29 13:55:38 +0100 |
commit | 4e74f32274bcbfd8b9c351b51a3fa9694fe9d452 (patch) | |
tree | bec9658b4b6df6485feb5824d2c5babd9e59cb14 /src | |
parent | ce1bf2b5293714a57dffacc3d07b8281d39f4b16 (diff) |
src: validate anim-atlas frames when loading
Diffstat (limited to 'src')
-rw-r--r-- | src/anim-atlas.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index 0c4d4f63..10d33bac 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -33,12 +33,22 @@ decltype(anim_atlas::_group_indices) anim_atlas::make_group_indices(const anim_d anim_atlas::anim_atlas() noexcept = default; anim_atlas::anim_atlas(StringView name, const ImageView2D& image, anim_def info) noexcept : - _name{name}, _bitmask{ make_bitmask(image)}, + _name{name}, _bitmask{make_bitmask(image)}, _info{std::move(info)}, _group_indices{make_group_indices(_info)} { const Size<3>& size = image.pixels().size(); fm_assert(size[0]*size[1] == _info.pixel_size.product()); fm_assert(size[2] >= 3 && size[2] <= 4); + + for (const auto pixel_size = _info.pixel_size; + const auto& group : _info.groups) + for (const auto& fr : group.frames) + { + fm_assert(fr.size.product() != 0); + fm_assert(fr.offset < pixel_size); + fm_assert(fr.offset + fr.size <= pixel_size); + } + _tex.setWrapping(GL::SamplerWrapping::ClampToEdge) .setMagnificationFilter(GL::SamplerFilter::Nearest) .setMinificationFilter(GL::SamplerFilter::Nearest) |