lib: add bounds to prevent out of bounds read panic

This commit is contained in:
Matt Bilker
2018-06-07 03:48:39 +00:00
parent 2459e0a13f
commit b2a316cf4c

View File

@@ -73,7 +73,8 @@ impl KbinXml {
// Remove trailing null bytes
let mut index = data.len() - 1;
while index > 0 && data[index] == 0x00 {
let len = data.len();
while index < len && data[index] == 0x00 {
index -= 1;
}
data.truncate(index + 1);