Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fixed memory overrun bug in gdImageScaleTwoPass
_gdContributionsCalc would compute a window size and then adjust
the left and right positions of the window to make a window within
that size.  However, it was storing the values in the struct *before*
it made the adjustment.  This change fixes that.
  • Loading branch information
suetanvil committed Sep 23, 2013
1 parent 3e76d30 commit 4f65a3e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gd_interpolation.c
Expand Up @@ -953,9 +953,6 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi
double dTotalWeight = 0.0;
int iSrc;

res->ContribRow[u].Left = iLeft;
res->ContribRow[u].Right = iRight;

/* Cut edge points to fit in filter window in case of spill-off */
if (iRight - iLeft + 1 > windows_size) {
if (iLeft < ((int)src_size - 1 / 2)) {
Expand All @@ -965,6 +962,9 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi
}
}

res->ContribRow[u].Left = iLeft;
res->ContribRow[u].Right = iRight;

for (iSrc = iLeft; iSrc <= iRight; iSrc++) {
dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc)));
}
Expand Down

0 comments on commit 4f65a3e

Please sign in to comment.