Skip to content

Commit

Permalink
Add explicit is_empty() check
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Jan 8, 2024
1 parent a66be1e commit 67937c4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sdk/src/types/block/output/feature/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ fn verify_keys_packable<const VERIFY: bool>(
>,
) -> Result<(), Error> {
if VERIFY {
if map.is_empty() {
return Err(Error::InvalidMetadataFeatureKeyLength(
MetadataFeatureKeyLength::try_from(0u8).unwrap_err().into(),
));
}
for key in map.keys() {
if !key.iter().all(|b| b.is_ascii_graphic()) {
return Err(Error::NonAsciiMetadataKey(key.to_vec()));
Expand Down

0 comments on commit 67937c4

Please sign in to comment.