mirror of
https://github.com/mbilker/kbinxml-rs.git
synced 2026-09-09 19:15:27 -05:00
byte_buffer: fix string handling when the string is only a single null byte
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kbinxml"
|
||||
version = "0.11.2"
|
||||
version = "0.11.3"
|
||||
authors = ["Matt Bilker <me@mbilker.us>"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -18,7 +18,13 @@ pub(crate) fn strip_trailing_null_bytes<'a>(data: &'a [u8]) -> &'a [u8] {
|
||||
while index > 0 && index < len && data[index] == 0x00 {
|
||||
index -= 1;
|
||||
}
|
||||
&data[..=index]
|
||||
|
||||
// Handle case where the buffer is only a null byte
|
||||
if index == 0 && data.len() == 1 && data[index] == 0x00 {
|
||||
&[]
|
||||
} else {
|
||||
&data[..=index]
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ByteBufferRead {
|
||||
|
||||
Reference in New Issue
Block a user