Skip to content

Commit c94d397

Browse files
committed
And or fragments must have exactly two arguments
1 parent 5356476 commit c94d397

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/policy/concrete.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ where
401401
hash160::Hash::from_hex(x).map(Policy::Hash160)
402402
}),
403403
("and", _) => {
404-
if top.args.is_empty() {
405-
return Err(errstr("and without args"));
404+
if top.args.len() != 2 {
405+
return Err(errstr("and fragment must have exactly two children"));
406406
}
407407
let mut subs = Vec::with_capacity(top.args.len());
408408
for arg in &top.args {
@@ -411,8 +411,8 @@ where
411411
Ok(Policy::And(subs))
412412
}
413413
("or", _) => {
414-
if top.args.is_empty() {
415-
return Err(errstr("or without args"));
414+
if top.args.len() != 2 {
415+
return Err(errstr("or fragment must have exactly two children"));
416416
}
417417
let mut subs = Vec::with_capacity(top.args.len());
418418
for arg in &top.args {

src/policy/semantic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ where
234234
hash160::Hash::from_hex(x).map(Policy::Hash160)
235235
}),
236236
("and", _) => {
237-
if top.args.is_empty() {
238-
return Err(errstr("and without args"));
237+
if top.args.len() != 2 {
238+
return Err(errstr("and fragment must have exactly two children"));
239239
}
240240
let mut subs = Vec::with_capacity(top.args.len());
241241
for arg in &top.args {
@@ -244,8 +244,8 @@ where
244244
Ok(Policy::And(subs))
245245
}
246246
("or", _) => {
247-
if top.args.is_empty() {
248-
return Err(errstr("or without args"));
247+
if top.args.len() != 2 {
248+
return Err(errstr("or fragment must have exactly two children"));
249249
}
250250
let mut subs = Vec::with_capacity(top.args.len());
251251
for arg in &top.args {

0 commit comments

Comments
 (0)