CVE-2026-51807: Openhtj2k Missing Bounds Check Num Passes

Accumulating values into `num_passes` without prior bounds checking allows out-of-bounds array indexing on the `pass_length` array, causing a heap buffer overflow. Calculate increments securely into a temporary variable and validate against maximum bounds before mutating `num_passes`.

Provally CuratedPublic repositoryHighMedium confidenceVerifiedApache-2.0C++
greprules fetch cve-2026-51807-openhtj2k-missing-bounds-check-num-passes --engine opengrep

Description

Accumulating values into `num_passes` without prior bounds checking allows out-of-bounds array indexing on the `pass_length` array, causing a heap buffer overflow. Calculate increments securely into a temporary variable and validate against maximum bounds before mutating `num_passes`.