diff --git a/svd-parser/src/bitrange.rs b/svd-parser/src/bitrange.rs index e8ed2c7c..0fb8ec4e 100644 --- a/svd-parser/src/bitrange.rs +++ b/svd-parser/src/bitrange.rs @@ -7,6 +7,7 @@ pub enum InvalidBitRange { ParseError, MsbLsb, Empty, + Size, } impl Parse for BitRange { @@ -83,6 +84,9 @@ impl Parse for BitRange { return Err(SVDError::InvalidBitRange(InvalidBitRange::Syntax).at(tree.id())); }; + if start > end { + return Err(SVDError::InvalidBitRange(InvalidBitRange::Size).at(tree.id())); + } Ok(Self { offset: start, width: end - start + 1, diff --git a/svd-rs/CHANGELOG.md b/svd-rs/CHANGELOG.md index 1c151db4..12333eb7 100644 --- a/svd-rs/CHANGELOG.md +++ b/svd-rs/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +- Add check for wrong size of `bitRange` width - Don't clone when serialize - Add optional entries to `Cpu` - `AddressBlock` & `Interrupt` now use builders