Skip to content
  • Rémi Denis-Courmont's avatar
    gradient: fix integer overflow · 0a0690cc
    Rémi Denis-Courmont authored
    If a and/or b is unsigned, a - b is unsigned.
    Then if a < b, a - b > INT_MAX.
    And then abs(a - b) performs an undefined implicit conversion to int.
    
    This converts to int before computing the difference. Since all samples
    are 8-bits unsigned, this cannot overflow.
    0a0690cc