Skip to content

Commit 187c885

Browse files
authored
fix: Panic when an extension name is too long. (#2198)
This PR fixes a bug that led to a panic in import when the name of an extension exceeded 23 bytes. This was caused by a misreading of `IdentList::new_unchecked`: this method not only avoids checking the identifier for validity but also assumes that the input will fit into the 23 byte inline capacity of a `SmolStr`.
1 parent 86cd0ab commit 187c885

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hugr-core/src/hugr/ident.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl IdentList {
5959
#[must_use]
6060
pub fn split_last(&self) -> Option<(IdentList, SmolStr)> {
6161
let (prefix, suffix) = self.0.rsplit_once('.')?;
62-
let prefix = Self::new_unchecked(prefix);
62+
let prefix = Self(SmolStr::new(prefix));
6363
let suffix = suffix.into();
6464
Some((prefix, suffix))
6565
}

0 commit comments

Comments
 (0)