mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Add minor checks of .ase header
This commit is contained in:
parent
1470108fff
commit
7355d0e2db
@ -1,5 +1,5 @@
|
||||
// Aseprite Document IO Library
|
||||
// Copyright (c) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (c) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -39,6 +39,22 @@ bool AsepriteDecoder::decode()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.depth != 32 &&
|
||||
header.depth != 16 &&
|
||||
header.depth != 8) {
|
||||
delegate()->error(
|
||||
fmt::format("Invalid color depth {0}",
|
||||
header.depth));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.width < 1 || header.height < 1) {
|
||||
delegate()->error(
|
||||
fmt::format("Invalid sprite size {0}x{1}",
|
||||
header.width, header.height));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the new sprite
|
||||
std::unique_ptr<doc::Sprite> sprite(
|
||||
new doc::Sprite(doc::ImageSpec(header.depth == 32 ? doc::ColorMode::RGB:
|
||||
|
Loading…
x
Reference in New Issue
Block a user