diff options
author | Pierre Joye <pierre.php@gmail.com> | 2016-07-19 19:35:40 +0700 |
---|---|---|
committer | Pierre Joye <pierre.php@gmail.com> | 2016-07-19 19:35:40 +0700 |
commit | 439e2ae516a6aa4117571e75cfcde5ac724eec06 (patch) | |
tree | c379de0d21c6a962aa0fea5cb795912723550597 /ext/gd | |
parent | 83d498dafd51cbd8839365e40b62dc8f4109a7dc (diff) | |
parent | 77a71cba20d67193309369ab05763c2e4430bc32 (diff) | |
download | php-git-439e2ae516a6aa4117571e75cfcde5ac724eec06.tar.gz |
Merge branch 'PHP-7.0'
* PHP-7.0:
#72482, Ilegal write/read access caused by gdImageAALine overflow
fix #72494, improve input color check and prevent issues when old gd are used, done before gd call
improve fix #72558, free contribRow as well
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/gd.c | 4 | ||||
-rw-r--r-- | ext/gd/libgd/gd.c | 49 | ||||
-rw-r--r-- | ext/gd/libgd/gd_interpolation.c | 1 |
3 files changed, 5 insertions, 49 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index c0319b2c93..119bc8fec4 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -4636,8 +4636,8 @@ PHP_FUNCTION(imagecropauto) break; case GD_CROP_THRESHOLD: - if (color < 0) { - php_error_docref(NULL, E_WARNING, "Color argument missing with threshold mode"); + if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Color argument missing with threshold mode"); RETURN_FALSE; } im_crop = gdImageCropThreshold(im, color, (float) threshold); diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 4292671417..a7e4d6bf8e 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1299,55 +1299,10 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) long x, y, inc; long dx, dy,tmp; - if (y1 < 0 && y2 < 0) { - return; - } - if (y1 < 0) { - x1 += (y1 * (x1 - x2)) / (y2 - y1); - y1 = 0; - } - if (y2 < 0) { - x2 += (y2 * (x1 - x2)) / (y2 - y1); - y2 = 0; - } - - /* bottom edge */ - if (y1 >= im->sy && y2 >= im->sy) { - return; - } - if (y1 >= im->sy) { - x1 -= ((im->sy - y1) * (x1 - x2)) / (y2 - y1); - y1 = im->sy - 1; - } - if (y2 >= im->sy) { - x2 -= ((im->sy - y2) * (x1 - x2)) / (y2 - y1); - y2 = im->sy - 1; - } - - /* left edge */ - if (x1 < 0 && x2 < 0) { - return; - } - if (x1 < 0) { - y1 += (x1 * (y1 - y2)) / (x2 - x1); - x1 = 0; - } - if (x2 < 0) { - y2 += (x2 * (y1 - y2)) / (x2 - x1); - x2 = 0; - } - /* right edge */ - if (x1 >= im->sx && x2 >= im->sx) { + /* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */ + if (!clip_1d(&x1,&y1,&x2,&y2,gdImageSX(im)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) { return; } - if (x1 >= im->sx) { - y1 -= ((im->sx - x1) * (y1 - y2)) / (x2 - x1); - x1 = im->sx - 1; - } - if (x2 >= im->sx) { - y2 -= ((im->sx - x2) * (y1 - y2)) / (x2 - x1); - x2 = im->sx - 1; - } dx = x2 - x1; dy = y2 - y1; diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 9a7789e365..fd91e56535 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -909,6 +909,7 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, for (i=0;i<=u;i++) { gdFree(res->ContribRow[i].Weights); } + gdFree(res->ContribRow); gdFree(res); return NULL; } |