Correct sanity-checking script_size calculation

GitHub-Pull: #26149
Rebased-From: 648f6950cd8d9ac767d76a1e302f37c611936a7a
This commit is contained in:
Pieter Wuille 2022-09-21 09:17:45 -04:00 committed by fanquake
parent da6fba6fe7
commit c97d924880
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -1221,7 +1221,7 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
// n = 1 here because we read the first WRAPPED_EXPR before reaching THRESH
to_parse.emplace_back(ParseContext::THRESH, 1, k);
to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
script_size += 2 + (k > 16);
script_size += 2 + (k > 16) + (k > 0x7f) + (k > 0x7fff) + (k > 0x7fffff);
} else if (Const("andor(", in)) {
to_parse.emplace_back(ParseContext::ANDOR, -1, -1);
to_parse.emplace_back(ParseContext::CLOSE_BRACKET, -1, -1);