We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63a0304 commit 0b91de1Copy full SHA for 0b91de1
src/blockdata/script.rs
@@ -239,9 +239,12 @@ pub fn read_scriptint(v: &[u8]) -> Result<i64, Error> {
239
/// else as true", except that the overflow rules don't apply.
240
#[inline]
241
pub fn read_scriptbool(v: &[u8]) -> bool {
242
- !(v.is_empty() ||
243
- ((v[v.len() - 1] == 0 || v[v.len() - 1] == 0x80) &&
244
- v.iter().rev().skip(1).all(|&w| w == 0)))
+ let last = match v.last() {
+ Some(last) => *last,
+ None => return false,
245
+ };
246
+
247
+ !((last == 0x00 || last == 0x80) && v.iter().rev().skip(1).all(|&b| b == 0))
248
}
249
250
/// Read a script-encoded unsigned integer
0 commit comments