diff --git a/td/telegram/PhotoSizeSource.hpp b/td/telegram/PhotoSizeSource.hpp index 2322f45f..fc673459 100644 --- a/td/telegram/PhotoSizeSource.hpp +++ b/td/telegram/PhotoSizeSource.hpp @@ -30,7 +30,13 @@ void store(const PhotoSizeSource::Thumbnail &source, StorerT &storer) { template void parse(PhotoSizeSource::Thumbnail &source, ParserT &parser) { - parse(source.file_type, parser); + int32 raw_type; + parse(raw_type, parser); + if (raw_type < 0 || raw_type >= static_cast(FileType::Size)) { + return parser.set_error("Wrong file type in PhotoSizeSource::Thumbnail"); + } + source.file_type = static_cast(raw_type); + parse(source.thumbnail_type, parser); if (source.thumbnail_type < 0 || source.thumbnail_type > 255) { parser.set_error("Wrong thumbnail type"); @@ -63,8 +69,7 @@ void parse(PhotoSizeSource::DialogPhoto &source, ParserT &parser) { switch (source.dialog_id.get_type()) { case DialogType::SecretChat: case DialogType::None: - parser.set_error("Invalid chat id"); - break; + return parser.set_error("Invalid chat id"); default: break; } diff --git a/td/telegram/files/FileType.h b/td/telegram/files/FileType.h index d9b10c9f..469cc786 100644 --- a/td/telegram/files/FileType.h +++ b/td/telegram/files/FileType.h @@ -14,7 +14,7 @@ namespace td { -enum class FileType : int8 { +enum class FileType : int32 { Thumbnail, ProfilePhoto, Photo,