[scan_hierarchy] make sure counts get reset at ref boundaries

This commit is contained in:
jan 2026-03-09 01:45:06 -07:00
commit e72b792f6f

View file

@ -220,10 +220,15 @@ def scan_hierarchy(stream: IO[bytes]) -> dict[bytes, dict[bytes, int]]:
colrow = COLROW.read_data(stream, size) colrow = COLROW.read_data(stream, size)
ref_count = colrow[0] * colrow[1] ref_count = colrow[0] * colrow[1]
elif tag == ENDEL.tag: elif tag == ENDEL.tag:
if ref_count is None: if ref_name is not None:
ref_count = 1 if ref_count is None:
assert ref_name is not None ref_count = 1
cur_structure[ref_name] += ref_count cur_structure[ref_name] += ref_count
ref_name = None
ref_count = None
elif tag in (SREF.tag, AREF.tag):
ref_name = None
ref_count = None
else: else:
stream.seek(size, io.SEEK_CUR) stream.seek(size, io.SEEK_CUR)
size, tag = Record.read_header(stream) size, tag = Record.read_header(stream)