Skip to content

Commit 3c3a228

Browse files
committed
fix references values for imagecrop rectangle array.
1 parent ccffbaf commit 3c3a228

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

ext/gd/gd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,7 +3881,7 @@ PHP_FUNCTION(imagecrop)
38813881

38823882
im = php_gd_libgdimageptr_from_zval_p(IM);
38833883

3884-
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "x", sizeof("x") -1)) != NULL) {
3884+
if ((tmp = zend_hash_str_find_deref(Z_ARRVAL_P(z_rect), "x", sizeof("x") -1)) != NULL) {
38853885
if (!php_gd_zval_try_get_c_int(tmp, "x", &rect.x)) {
38863886
RETURN_THROWS();
38873887
}
@@ -3890,7 +3890,7 @@ PHP_FUNCTION(imagecrop)
38903890
RETURN_THROWS();
38913891
}
38923892

3893-
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
3893+
if ((tmp = zend_hash_str_find_deref(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
38943894
if (!php_gd_zval_try_get_c_int(tmp, "y", &rect.y)) {
38953895
RETURN_THROWS();
38963896
}
@@ -3899,7 +3899,7 @@ PHP_FUNCTION(imagecrop)
38993899
RETURN_THROWS();
39003900
}
39013901

3902-
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
3902+
if ((tmp = zend_hash_str_find_deref(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
39033903
if (!php_gd_zval_try_get_c_int(tmp, "width", &rect.width)) {
39043904
RETURN_THROWS();
39053905
}
@@ -3908,7 +3908,7 @@ PHP_FUNCTION(imagecrop)
39083908
RETURN_THROWS();
39093909
}
39103910

3911-
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
3911+
if ((tmp = zend_hash_str_find_deref(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
39123912
if (!php_gd_zval_try_get_c_int(tmp, "height", &rect.height)) {
39133913
RETURN_THROWS();
39143914
}

ext/gd/tests/gh18005.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ try {
6969
try {
7070
imagecrop($img, ["x" => 0, "y" => 0, "width" => 0, "height" => new A()]);
7171
} catch (\ValueError $e) {
72-
echo $e->getMessage();
72+
echo $e->getMessage() . PHP_EOL;
7373
}
74+
75+
$one = 1;
76+
var_dump(imagecrop($img, ["x" => &$one, "y" => &$one, "width" => &$one, "height" => &$one]));
7477
?>
7578
--EXPECTF--
7679
imagesetstyle(): Argument #2 ($style) must only have element of type int, A given
@@ -85,3 +88,5 @@ imagecrop(): Argument #2 ($rectangle) "x" key must be of type int, A given
8588
imagecrop(): Argument #2 ($rectangle) "y" key must be of type int, A given
8689
imagecrop(): Argument #2 ($rectangle) "width" key must be of type int, A given
8790
imagecrop(): Argument #2 ($rectangle) "height" key must be of type int, A given
91+
object(GdImage)#2 (0) {
92+
}

0 commit comments

Comments
 (0)