validate_data_value_pointers

Function validate_data_value_pointers 

Source
pub fn validate_data_value_pointers(
    data_section: &[u8],
    offset: usize,
    path: &mut HashSet<usize>,
    depth: usize,
) -> Result<usize, PointerValidationError>
Expand description

Validate a data value and all pointers it contains

Returns the maximum depth of pointer chains encountered. Detects cycles using the visited set.

§Arguments

  • data_section - Raw data section bytes
  • offset - Offset within data section to start validation
  • path - Set of offsets in the current traversal path (for cycle detection)
  • depth - Current depth in pointer chain

§Returns

  • Ok(max_depth) - Maximum depth reached
  • Err - Validation error encountered

§Note

The path set tracks ancestors in the current traversal path, not all visited nodes. This allows legitimate pointer reuse (data deduplication) while still detecting true cycles where a value references itself or an ancestor.