Skip to content

Commit 86f4561

Browse files
committed
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.
1 parent 20da637 commit 86f4561

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/aml/object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl Object {
316316
*value = u64::from_le_bytes(bytes);
317317
}
318318
Object::String(value) => {
319-
*value = String::from_utf8_lossy(&new_bytes).to_string();
319+
*value = String::from_utf8_lossy(&new_bytes).split('\0').next().unwrap().to_string();
320320
}
321321
Object::Buffer(value) => {
322322
*value = new_bytes.to_vec();

0 commit comments

Comments
 (0)