From 3d3736effec5b9497917062fc2fbdbc13d9e1503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Tue, 17 Oct 2023 20:32:45 +0200 Subject: [PATCH] Check that poll answer index is not negative --- cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs index 332df2f6c5..6f7f0ea2e8 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs @@ -129,7 +129,8 @@ runGovernanceAnswerPoll _ pollFile maybeChoice mOutFile = do validateChoice :: GovernancePoll -> Word -> ExceptT GovernanceCmdError IO () validateChoice GovernancePoll{govPollAnswers} ix = do let maxAnswerIndex = length govPollAnswers - 1 - when (fromIntegral ix > maxAnswerIndex) $ left $ + ixInt = fromIntegral ix + when (ixInt < 0 || ixInt > maxAnswerIndex) $ left $ GovernanceCmdPollOutOfBoundAnswer maxAnswerIndex askInteractively :: GovernancePoll -> ExceptT GovernanceCmdError IO Word