diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 847e0835bad4f..2585923edcc22 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -3417,7 +3417,7 @@ PHP_FUNCTION(imageconvolution) } for (i=0; i<3; i++) { - if ((var = zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) { + if ((var = zend_hash_index_find_deref(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) { if (zend_hash_num_elements(Z_ARRVAL_P(var)) != 3 ) { zend_argument_value_error(2, "must be a 3x3 array, matrix[%d] only has %d elements", i, zend_hash_num_elements(Z_ARRVAL_P(var))); RETURN_THROWS(); @@ -3697,7 +3697,7 @@ PHP_FUNCTION(imageaffine) } for (i = 0; i < nelems; i++) { - if ((zval_affine_elem = zend_hash_index_find(Z_ARRVAL_P(z_affine), i)) != NULL) { + if ((zval_affine_elem = zend_hash_index_find_deref(Z_ARRVAL_P(z_affine), i)) != NULL) { switch (Z_TYPE_P(zval_affine_elem)) { case IS_LONG: affine[i] = Z_LVAL_P(zval_affine_elem); @@ -3873,7 +3873,7 @@ PHP_FUNCTION(imageaffinematrixconcat) } for (i = 0; i < 6; i++) { - if ((tmp = zend_hash_index_find(Z_ARRVAL_P(z_m1), i)) != NULL) { + if ((tmp = zend_hash_index_find_deref(Z_ARRVAL_P(z_m1), i)) != NULL) { switch (Z_TYPE_P(tmp)) { case IS_LONG: m1[i] = Z_LVAL_P(tmp); @@ -3890,7 +3890,7 @@ PHP_FUNCTION(imageaffinematrixconcat) } } - if ((tmp = zend_hash_index_find(Z_ARRVAL_P(z_m2), i)) != NULL) { + if ((tmp = zend_hash_index_find_deref(Z_ARRVAL_P(z_m2), i)) != NULL) { switch (Z_TYPE_P(tmp)) { case IS_LONG: m2[i] = Z_LVAL_P(tmp); diff --git a/ext/gd/tests/gh17984.phpt b/ext/gd/tests/gh17984.phpt new file mode 100644 index 0000000000000..c46c455799e0f --- /dev/null +++ b/ext/gd/tests/gh17984.phpt @@ -0,0 +1,44 @@ +--TEST-- +GH-17984: array of references handling +--EXTENSIONS-- +gd +--FILE-- + +--EXPECT-- +object(GdImage)#2 (0) { +} +array(6) { + [0]=> + float(2028) + [1]=> + float(46) + [2]=> + float(138) + [3]=> + float(4) + [4]=> + float(233) + [5]=> + float(7) +} +bool(true) +bool(true) +bool(true)