Skip to content

Commit 6146d0f

Browse files
committed
Error if DefPackage doesn't contain correct number of elements
1 parent 9d4bba2 commit 6146d0f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

aml/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ pub enum AmlError {
619619
UnterminatedStringConstant,
620620
InvalidStringConstant,
621621
InvalidRegionSpace(u8),
622+
/// Produced when a `DefPackage` contains a different number of elements to the package's length.
623+
InvalidPackage,
622624
/// Emitted by a parser when it's clear that the stream doesn't encode the object parsed by
623625
/// that parser (e.g. the wrong opcode starts the stream). This is handled specially by some
624626
/// parsers such as `or` and `choice!`.

aml/src/type2.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ where
276276
package_contents.push(value);
277277
}
278278

279-
assert_eq!(package_contents.len(), num_elements as usize);
279+
if package_contents.len() != num_elements as usize {
280+
return Err((input, context, AmlError::InvalidPackage));
281+
}
282+
280283
Ok((input, context, AmlValue::Package(package_contents)))
281284
}
282285
}),

0 commit comments

Comments
 (0)