Skip to content

Commit

Permalink
mapquantization.c: fix Unintended sign extension (CID 1174447, 117444…
Browse files Browse the repository at this point in the history
…8, 1174449, 1174450)
  • Loading branch information
rouault committed May 22, 2021
1 parent 4ec0f76 commit a3105dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mapquantization.c
Expand Up @@ -495,10 +495,10 @@ mediancut( acolorhist_vector achv, int colors, int sum, unsigned char maxval, in
register long r = 0, g = 0, b = 0, a = 0, sum = 0;

for ( i = 0; i < clrs; ++i ) {
r += PAM_GETR( achv[indx + i].acolor ) * achv[indx + i].value;
g += PAM_GETG( achv[indx + i].acolor ) * achv[indx + i].value;
b += PAM_GETB( achv[indx + i].acolor ) * achv[indx + i].value;
a += PAM_GETA( achv[indx + i].acolor ) * achv[indx + i].value;
r += (long)PAM_GETR( achv[indx + i].acolor ) * achv[indx + i].value;
g += (long)PAM_GETG( achv[indx + i].acolor ) * achv[indx + i].value;
b += (long)PAM_GETB( achv[indx + i].acolor ) * achv[indx + i].value;
a += (long)PAM_GETA( achv[indx + i].acolor ) * achv[indx + i].value;
sum += achv[indx + i].value;
}
if(sum>0) {
Expand Down

0 comments on commit a3105dc

Please sign in to comment.