File tree Expand file tree Collapse file tree 2 files changed +40
-4
lines changed
Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -698,8 +698,26 @@ pub(super) fn parse_extension_to_index(
698698 // record (e.g., large files with extensive run lists).
699699 if found_default_data {
700700 let record = & mut index. records [ record_idx as usize ] ;
701- record. first_stream . size . length = default_data_size;
702- record. first_stream . size . allocated = default_data_allocated;
701+
702+ // If base record has no $DATA (both fields are 0), use extension's $DATA.
703+ // Otherwise, accumulate extension $DATA to base $DATA.
704+ if record. first_stream . size . length == 0 && record. first_stream . size . allocated == 0 {
705+ // Base has no $DATA — use extension's values
706+ record. first_stream . size . length = default_data_size;
707+ record. first_stream . size . allocated = default_data_allocated;
708+ } else {
709+ // Base has partial $DATA — accumulate extension values
710+ record. first_stream . size . length = record
711+ . first_stream
712+ . size
713+ . length
714+ . saturating_add ( default_data_size) ;
715+ record. first_stream . size . allocated = record
716+ . first_stream
717+ . size
718+ . allocated
719+ . saturating_add ( default_data_allocated) ;
720+ }
703721 }
704722
705723 // Merge directory index sizes from extension records
Original file line number Diff line number Diff line change @@ -706,8 +706,26 @@ pub(super) fn parse_extension_to_index(
706706 // record (e.g., large files with extensive run lists).
707707 if found_default_data {
708708 let record = & mut index. records [ record_idx as usize ] ;
709- record. first_stream . size . length = default_data_size;
710- record. first_stream . size . allocated = default_data_allocated;
709+
710+ // If base record has no $DATA (both fields are 0), use extension's $DATA.
711+ // Otherwise, accumulate extension $DATA to base $DATA.
712+ if record. first_stream . size . length == 0 && record. first_stream . size . allocated == 0 {
713+ // Base has no $DATA — use extension's values
714+ record. first_stream . size . length = default_data_size;
715+ record. first_stream . size . allocated = default_data_allocated;
716+ } else {
717+ // Base has partial $DATA — accumulate extension values
718+ record. first_stream . size . length = record
719+ . first_stream
720+ . size
721+ . length
722+ . saturating_add ( default_data_size) ;
723+ record. first_stream . size . allocated = record
724+ . first_stream
725+ . size
726+ . allocated
727+ . saturating_add ( default_data_allocated) ;
728+ }
711729 }
712730
713731 // Merge directory index sizes from extension records
You can’t perform that action at this time.
0 commit comments