diff options
Diffstat (limited to 'src/serialized_file.rs')
-rw-r--r-- | src/serialized_file.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/serialized_file.rs b/src/serialized_file.rs index 9397d53..26f9391 100644 --- a/src/serialized_file.rs +++ b/src/serialized_file.rs @@ -3,7 +3,7 @@ use crate::{ helper::{AlignExt, Endianness, ReadExt}, }; use anyhow::{Result, bail}; -use log::{debug, info, trace}; +use log::{debug, info, trace, warn}; use std::io::{Cursor, Read, Seek}; #[derive(Debug, Clone)] @@ -163,7 +163,12 @@ pub fn read_serialized_file(mut file: impl Read + Seek) -> Result<SerializedFile let get_string = |off: u32| { let data = if off & 0x80000000 != 0 { let off = off & 0x7fffffff; - &COMMON_STRINGS[off as usize..] + if off as usize > COMMON_STRINGS.len() { + warn!("common strings missing index {off:08x}"); + b"<common string missing>" + } else { + &COMMON_STRINGS[off as usize..] + } } else { &string_data[off as usize..] }; @@ -189,6 +194,10 @@ pub fn read_serialized_file(mut file: impl Read + Seek) -> Result<SerializedFile ref_type_hash: node_data.read_u64(e)?, children: vec![], }; + if node.level == 0 && !parents.is_empty() { + warn!("unexpected toplevel typetree node"); + parents.clear(); + } while parents.len() > node.level as usize { let n = parents.pop().unwrap(); parents.last_mut().unwrap().children.push(n) |