diff options
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/utils.rs b/src/utils.rs index 25470e7..559c70c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -43,7 +43,8 @@ pub fn read_utf16_string<T: ReadSeek>(stream: &mut T, len: Option<usize>) -> io: }, } - decode_utf16(buffer.into_iter()) + // We need to stop if we see a NUL byte, even if asked for more bytes. + decode_utf16(buffer.into_iter().take_while(|&byte| byte != 0x00)) .map(|r| r.map_err(|_e| io::Error::from(io::ErrorKind::InvalidData))) .collect() } |