From 66b805f8e104a2bf51bcdddc0d28dc4b5f3849d0 Mon Sep 17 00:00:00 2001 From: Isaac Woods Date: Fri, 29 May 2026 12:09:39 +0100 Subject: [PATCH] Fix regression in implicit casting from integer -> string Modelling AML strings in Rust is tricky; conversion from integers with `String::from_utf8_lossy` keeps trailing null bytes - this is likely fine in C because of how string comparisons would work, but trips up comparison in Rust's `String` (and `CString` cannot have multiple trailing null bytes). This fixes a regression in uACPI's implicit_case_semantics by removing trailing null bytes when doing an integer -> string conversion. It may be that the correct place to fix this holistically is rather in the object comparsion, but this seems like a reasonable step given the current failing case. --- src/aml/object.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aml/object.rs b/src/aml/object.rs index ddf8ce7d..7d78447a 100644 --- a/src/aml/object.rs +++ b/src/aml/object.rs @@ -316,7 +316,7 @@ impl Object { *value = u64::from_le_bytes(bytes); } Object::String(value) => { - *value = String::from_utf8_lossy(&new_bytes).to_string(); + *value = String::from_utf8_lossy(&new_bytes).split('\0').next().unwrap().to_string(); } Object::Buffer(value) => { *value = new_bytes.to_vec();