From 91c497ff13e20b6838cc4aa2b23d15f3f56fe0a9 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Tue, 10 Oct 2023 17:28:43 +0800 Subject: [PATCH] chore: catch overflow --- libs/jwst-codec/src/doc/store.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/jwst-codec/src/doc/store.rs b/libs/jwst-codec/src/doc/store.rs index 8126997c..89d9a973 100644 --- a/libs/jwst-codec/src/doc/store.rs +++ b/libs/jwst-codec/src/doc/store.rs @@ -615,7 +615,9 @@ impl DocStore { // 3. adjust parent length if item.parent_sub.is_none() && item.countable() { if let Some(parent) = parent { - parent.len -= item.len(); + if parent.len != 0 { + parent.len -= item.len(); + } } else if let Some(Parent::Type(ty)) = &item.parent { ty.ty_mut().unwrap().len -= item.len(); }