mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#32255: miniscript: Correct off-by-one assert guards (#31727 follow-up)
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Windows native, VS 2022 (push) Waiting to run
CI / Windows native, fuzz, VS 2022 (push) Waiting to run
CI / Linux->Windows cross, no tests (push) Waiting to run
CI / Windows, test cross-built (push) Blocked by required conditions
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
3693e4d6ee
miniscript: Correct off-by-one assert guards (Hodlinator) Pull request description: First instances discovered by darosior in https://github.com/bitcoin/bitcoin/pull/31727#issuecomment-2619342125. ACKs for top commit: maflcko: lgtm ACK3693e4d6ee
sipa: ACK3693e4d6ee
l0rinc: Tested ACK3693e4d6ee
Tree-SHA512: a41302bb9349d5ad2daf89431c67fdbe80f91690e1759d01529acd1b2fa5d99bad3383da684ee62c00584f7696cd3f87efff084c74edf52eb7cd88d60ee99829
This commit is contained in:
commit
5116655980
1 changed files with 5 additions and 5 deletions
|
@ -1009,7 +1009,7 @@ private:
|
||||||
next_sats.push_back(sats[sats.size() - 1] + sub->ops.sat);
|
next_sats.push_back(sats[sats.size() - 1] + sub->ops.sat);
|
||||||
sats = std::move(next_sats);
|
sats = std::move(next_sats);
|
||||||
}
|
}
|
||||||
assert(k <= sats.size());
|
assert(k < sats.size());
|
||||||
return {count, sats[k], sats[0]};
|
return {count, sats[k], sats[0]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1177,7 @@ private:
|
||||||
next_sats.push_back(sats[sats.size() - 1] + sub->ws.sat);
|
next_sats.push_back(sats[sats.size() - 1] + sub->ws.sat);
|
||||||
sats = std::move(next_sats);
|
sats = std::move(next_sats);
|
||||||
}
|
}
|
||||||
assert(k <= sats.size());
|
assert(k < sats.size());
|
||||||
return {sats[k], sats[0]};
|
return {sats[k], sats[0]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1227,7 +1227,7 @@ private:
|
||||||
// satisfying 0 keys.
|
// satisfying 0 keys.
|
||||||
auto& nsat{sats[0]};
|
auto& nsat{sats[0]};
|
||||||
CHECK_NONFATAL(node.k != 0);
|
CHECK_NONFATAL(node.k != 0);
|
||||||
assert(node.k <= sats.size());
|
assert(node.k < sats.size());
|
||||||
return {std::move(nsat), std::move(sats[node.k])};
|
return {std::move(nsat), std::move(sats[node.k])};
|
||||||
}
|
}
|
||||||
case Fragment::MULTI: {
|
case Fragment::MULTI: {
|
||||||
|
@ -1253,7 +1253,7 @@ private:
|
||||||
// The dissatisfaction consists of k+1 stack elements all equal to 0.
|
// The dissatisfaction consists of k+1 stack elements all equal to 0.
|
||||||
InputStack nsat = ZERO;
|
InputStack nsat = ZERO;
|
||||||
for (size_t i = 0; i < node.k; ++i) nsat = std::move(nsat) + ZERO;
|
for (size_t i = 0; i < node.k; ++i) nsat = std::move(nsat) + ZERO;
|
||||||
assert(node.k <= sats.size());
|
assert(node.k < sats.size());
|
||||||
return {std::move(nsat), std::move(sats[node.k])};
|
return {std::move(nsat), std::move(sats[node.k])};
|
||||||
}
|
}
|
||||||
case Fragment::THRESH: {
|
case Fragment::THRESH: {
|
||||||
|
@ -1288,7 +1288,7 @@ private:
|
||||||
// Include all dissatisfactions (even these non-canonical ones) in nsat.
|
// Include all dissatisfactions (even these non-canonical ones) in nsat.
|
||||||
if (i != node.k) nsat = std::move(nsat) | std::move(sats[i]);
|
if (i != node.k) nsat = std::move(nsat) | std::move(sats[i]);
|
||||||
}
|
}
|
||||||
assert(node.k <= sats.size());
|
assert(node.k < sats.size());
|
||||||
return {std::move(nsat), std::move(sats[node.k])};
|
return {std::move(nsat), std::move(sats[node.k])};
|
||||||
}
|
}
|
||||||
case Fragment::OLDER: {
|
case Fragment::OLDER: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue