diff --git a/src/dio/aseprite_decoder.cpp b/src/dio/aseprite_decoder.cpp index fceaa0a60..2dd8e2470 100644 --- a/src/dio/aseprite_decoder.cpp +++ b/src/dio/aseprite_decoder.cpp @@ -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 sprite( new doc::Sprite(doc::ImageSpec(header.depth == 32 ? doc::ColorMode::RGB: