Skip to content

Commit 925bc0f

Browse files
author
Ilia Alshanetsky
committed
Fix segfault in imagecopyresized().
1 parent 9982484 commit 925bc0f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ext/gd/gd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,11 @@ PHP_FUNCTION(imagecopyresized)
29462946
dstY = Z_LVAL_PP(DY);
29472947
dstH = Z_LVAL_PP(DH);
29482948
dstW = Z_LVAL_PP(DW);
2949+
2950+
if (dstW < 0 || dstH < 0 || srcW < 0 || srcH < 0) {
2951+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid image dimensions");
2952+
RETURN_FALSE;
2953+
}
29492954

29502955
gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
29512956
RETURN_TRUE;

0 commit comments

Comments
 (0)