Skip to content

Commit 5116655

Browse files
committed
Merge bitcoin/bitcoin#32255: miniscript: Correct off-by-one assert guards (#31727 follow-up)
3693e4d miniscript: Correct off-by-one assert guards (Hodlinator) Pull request description: First instances discovered by darosior in bitcoin/bitcoin#31727 (comment). ACKs for top commit: maflcko: lgtm ACK 3693e4d sipa: ACK 3693e4d l0rinc: Tested ACK 3693e4d Tree-SHA512: a41302bb9349d5ad2daf89431c67fdbe80f91690e1759d01529acd1b2fa5d99bad3383da684ee62c00584f7696cd3f87efff084c74edf52eb7cd88d60ee99829
2 parents 817edfb + 3693e4d commit 5116655

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/script/miniscript.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ struct Node {
10091009
next_sats.push_back(sats[sats.size() - 1] + sub->ops.sat);
10101010
sats = std::move(next_sats);
10111011
}
1012-
assert(k <= sats.size());
1012+
assert(k < sats.size());
10131013
return {count, sats[k], sats[0]};
10141014
}
10151015
}
@@ -1177,7 +1177,7 @@ struct Node {
11771177
next_sats.push_back(sats[sats.size() - 1] + sub->ws.sat);
11781178
sats = std::move(next_sats);
11791179
}
1180-
assert(k <= sats.size());
1180+
assert(k < sats.size());
11811181
return {sats[k], sats[0]};
11821182
}
11831183
}
@@ -1227,7 +1227,7 @@ struct Node {
12271227
// satisfying 0 keys.
12281228
auto& nsat{sats[0]};
12291229
CHECK_NONFATAL(node.k != 0);
1230-
assert(node.k <= sats.size());
1230+
assert(node.k < sats.size());
12311231
return {std::move(nsat), std::move(sats[node.k])};
12321232
}
12331233
case Fragment::MULTI: {
@@ -1253,7 +1253,7 @@ struct Node {
12531253
// The dissatisfaction consists of k+1 stack elements all equal to 0.
12541254
InputStack nsat = ZERO;
12551255
for (size_t i = 0; i < node.k; ++i) nsat = std::move(nsat) + ZERO;
1256-
assert(node.k <= sats.size());
1256+
assert(node.k < sats.size());
12571257
return {std::move(nsat), std::move(sats[node.k])};
12581258
}
12591259
case Fragment::THRESH: {
@@ -1288,7 +1288,7 @@ struct Node {
12881288
// Include all dissatisfactions (even these non-canonical ones) in nsat.
12891289
if (i != node.k) nsat = std::move(nsat) | std::move(sats[i]);
12901290
}
1291-
assert(node.k <= sats.size());
1291+
assert(node.k < sats.size());
12921292
return {std::move(nsat), std::move(sats[node.k])};
12931293
}
12941294
case Fragment::OLDER: {

0 commit comments

Comments
 (0)