From 3df2fbc072a00ce2631016528a948f991b942ace Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 1 May 2024 18:05:11 +0300 Subject: [PATCH] Fix correct_option_id check. --- td/telegram/PollManager.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/td/telegram/PollManager.hpp b/td/telegram/PollManager.hpp index c28e97a8d..88ba03545 100644 --- a/td/telegram/PollManager.hpp +++ b/td/telegram/PollManager.hpp @@ -218,7 +218,6 @@ PollId PollManager::parse_poll(ParserT &parser) { PollId poll_id(poll_id_int); if (is_local_poll_id(poll_id)) { FormattedText question; - vector options; FormattedText explanation; int32 open_period = 0; int32 close_date = 0; @@ -251,7 +250,7 @@ PollId PollManager::parse_poll(ParserT &parser) { parse(option_texts, parser); if (is_quiz) { parse(correct_option_id, parser); - if (correct_option_id < -1 || correct_option_id >= static_cast(options.size())) { + if (correct_option_id < -1 || correct_option_id >= static_cast(option_texts.size())) { parser.set_error("Wrong local quiz correct_option_id"); } } @@ -274,9 +273,11 @@ PollId PollManager::parse_poll(ParserT &parser) { } else { option_entities.resize(option_texts.size()); } + vector options; for (size_t i = 0; i < option_texts.size(); i++) { options.push_back({std::move(option_texts[i]), std::move(option_entities[i])}); } + if (parser.get_error() != nullptr) { return PollId(); }