Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab6e87d

Browse files
committed
add test
1 parent ff549d1 commit ab6e87d

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

ext/gd/libgd/gd_interpolation.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -954,20 +954,20 @@ static inline void _gdScaleRow(gdImagePtr pSrc, unsigned int src_width, gdImage
954954
unsigned int x;
955955

956956
for (x = 0; x < dst_width; x++) {
957-
double r = 0, g = 0, b = 0, a = 0;
957+
double r = 0, g = 0, b = 0, a = 0;
958958
const int left = contrib->ContribRow[x].Left;
959959
const int right = contrib->ContribRow[x].Right;
960-
int i;
960+
int i;
961961

962962
/* Accumulate each channel */
963-
for (i = left; i <= right; i++) {
964-
const int left_channel = i - left;
965-
r += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetRed(p_src_row[i]));
966-
g += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetGreen(p_src_row[i]));
967-
b += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetBlue(p_src_row[i]));
968-
a += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetAlpha(p_src_row[i]));
969-
}
970-
p_dst_row[x] = gdTrueColorAlpha(uchar_clamp(r), uchar_clamp(g), uchar_clamp(b), uchar_clamp(a));
963+
for (i = left; i <= right; i++) {
964+
const int left_channel = i - left;
965+
r += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetRed(p_src_row[i]));
966+
g += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetGreen(p_src_row[i]));
967+
b += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetBlue(p_src_row[i]));
968+
a += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetAlpha(p_src_row[i]));
969+
}
970+
p_dst_row[x] = gdTrueColorAlpha(uchar_clamp(r), uchar_clamp(g), uchar_clamp(b), uchar_clamp(a));
971971
}
972972
}
973973

ext/gd/tests/gh16257.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-16257 (underflow on RBG channels handling with imagescale)
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
$im = imagecreatefromstring(file_get_contents(__DIR__ . '/imagecreatefromstring.gif'));
8+
imagescale($im, 32, 32, IMG_BICUBIC);
9+
echo "DONE";
10+
?>
11+
--EXPECT--
12+
DONE

0 commit comments

Comments
 (0)