Skip to content

Commit 4f65a3e

Browse files
committed
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.
1 parent 3e76d30 commit 4f65a3e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: src/gd_interpolation.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,6 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi
953953
double dTotalWeight = 0.0;
954954
int iSrc;
955955

956-
res->ContribRow[u].Left = iLeft;
957-
res->ContribRow[u].Right = iRight;
958-
959956
/* Cut edge points to fit in filter window in case of spill-off */
960957
if (iRight - iLeft + 1 > windows_size) {
961958
if (iLeft < ((int)src_size - 1 / 2)) {
@@ -965,6 +962,9 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi
965962
}
966963
}
967964

965+
res->ContribRow[u].Left = iLeft;
966+
res->ContribRow[u].Right = iRight;
967+
968968
for (iSrc = iLeft; iSrc <= iRight; iSrc++) {
969969
dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc)));
970970
}

0 commit comments

Comments
 (0)