Skip to content
Permalink
Browse files
Error if DefPackage doesn't contain correct number of elements
  • Loading branch information
IsaacWoods committed Dec 18, 2020
1 parent 9d4bba2 commit 6146d0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
@@ -619,6 +619,8 @@ pub enum AmlError {
UnterminatedStringConstant,
InvalidStringConstant,
InvalidRegionSpace(u8),
/// Produced when a `DefPackage` contains a different number of elements to the package's length.
InvalidPackage,
/// Emitted by a parser when it's clear that the stream doesn't encode the object parsed by
/// that parser (e.g. the wrong opcode starts the stream). This is handled specially by some
/// parsers such as `or` and `choice!`.
@@ -276,7 +276,10 @@ where
package_contents.push(value);
}

assert_eq!(package_contents.len(), num_elements as usize);
if package_contents.len() != num_elements as usize {
return Err((input, context, AmlError::InvalidPackage));
}

Ok((input, context, AmlValue::Package(package_contents)))
}
}),

0 comments on commit 6146d0f

Please sign in to comment.