From 85f6074a48ba20a35f7430eafa7760b3d7e70da0 Mon Sep 17 00:00:00 2001 From: "Carson M." Date: Fri, 20 Mar 2026 19:43:49 -0500 Subject: [PATCH] fix: string attributes in `ShapeInferenceContext` --- src/operator/attribute.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/operator/attribute.rs b/src/operator/attribute.rs index 73e9c66..87ef7cb 100644 --- a/src/operator/attribute.rs +++ b/src/operator/attribute.rs @@ -197,9 +197,9 @@ impl FromOpAttr for String { where Self: Sized { - let mut out = vec![0_u8; len]; - ortsys![unsafe ReadOpAttr(attr, ort_sys::OrtOpAttrType::ORT_OP_ATTR_STRING, out.as_mut_ptr().cast(), len, &mut len)?]; - debug_assert_eq!(out.len(), len, "int attribute is smaller/larger than expected"); + let mut out = vec![0_u8; len + 1]; + ortsys![unsafe ReadOpAttr(attr, ort_sys::OrtOpAttrType::ORT_OP_ATTR_STRING, out.as_mut_ptr().cast(), len + 1, &mut len)?]; + debug_assert_eq!(out.len(), len + 1, "string attribute is smaller/larger than expected"); CString::from_vec_with_nul(out) .map_err(|_| Error::new("invalid string attribute contents")) .and_then(|f| f.into_string().map_err(|_| Error::new("invalid string attribute contents")))