File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,8 @@ pub(super) fn parse_extension_to_index(
505505 let record_idx = index. frs_to_idx [ base_frs_usize] ;
506506 if record_idx != NO_ENTRY {
507507 let record = & mut index. records [ record_idx as usize ] ;
508+ // Snapshot name_count BEFORE link-chaining modifies it (for child entries)
509+ let pre_chain_name_count = record. name_count ;
508510
509511 // Add new links to the record
510512 if !link_indices. is_empty ( ) {
@@ -682,9 +684,8 @@ pub(super) fn parse_extension_to_index(
682684
683685 // Build parent-child relationship for names added from extension records
684686 // This is critical for compute_tree_metrics() to work correctly.
685- // Get the current name_count to determine the name_index for each new name
686- let record = & index. records [ record_idx as usize ] ;
687- let existing_name_count = record. name_count ;
687+ // Use the name_count from BEFORE link-chaining to avoid overflow
688+ let existing_name_count = pre_chain_name_count;
688689
689690 for ( name_idx, ( _, parent_frs) ) in names. iter ( ) . enumerate ( ) {
690691 let p_frs = * parent_frs;
Original file line number Diff line number Diff line change @@ -600,6 +600,8 @@ pub(super) fn parse_extension_to_index(
600600 let record_idx = index. frs_to_idx [ base_frs_usize] ;
601601 if record_idx != NO_ENTRY {
602602 let record = & mut index. records [ record_idx as usize ] ;
603+ // Snapshot name_count BEFORE link-chaining modifies it (for child entries)
604+ let pre_chain_name_count = record. name_count ;
603605
604606 // Add new links to the record
605607 if !link_indices. is_empty ( ) {
@@ -719,9 +721,8 @@ pub(super) fn parse_extension_to_index(
719721
720722 // Build parent-child relationship for names added from extension records
721723 // This is critical for compute_tree_metrics() to work correctly.
722- // Get the current name_count to determine the name_index for each new name
723- let record = & index. records [ record_idx as usize ] ;
724- let existing_name_count = record. name_count ;
724+ // Use the name_count from BEFORE link-chaining to avoid overflow
725+ let existing_name_count = pre_chain_name_count;
725726
726727 for ( name_idx, ( _, parent_frs) ) in names. iter ( ) . enumerate ( ) {
727728 let p_frs = * parent_frs;
You can’t perform that action at this time.
0 commit comments