--- /dev/null
+--TEST--
+Bug #54305 (Crash in gc_remove_zval_from_buffer)
+--FILE--
+<?php
+class TestClass {
+ public function methodWithArgs($a, $b) {
+ }
+}
+abstract class AbstractClass {
+}
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+echo $methodWithArgs++;
+?>
+--EXPECTF--
+Method [ <user> public method methodWithArgs ] {
+ @@ %sbug54305.php %d - %d
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $a ]
+ Parameter #1 [ <required> $b ]
+ }
+}
zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R);
if (OP1_TYPE != IS_CONST &&
- Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
- zend_print_variable(&z_copy);
- zval_dtor(&z_copy);
+ Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL) {
+ if (OP1_TYPE == IS_TMP_VAR) {
+ INIT_PZVAL(z);
+ }
+ if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
+ zend_print_variable(&z_copy);
+ zval_dtor(&z_copy);
+ } else {
+ zend_print_variable(z);
+ }
} else {
zend_print_variable(z);
}
zval *z = &opline->op1.u.constant;
if (IS_CONST != IS_CONST &&
- Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
- zend_print_variable(&z_copy);
- zval_dtor(&z_copy);
+ Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL) {
+ if (IS_CONST == IS_TMP_VAR) {
+ INIT_PZVAL(z);
+ }
+ if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
+ zend_print_variable(&z_copy);
+ zval_dtor(&z_copy);
+ } else {
+ zend_print_variable(z);
+ }
} else {
zend_print_variable(z);
}
zval *z = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
if (IS_TMP_VAR != IS_CONST &&
- Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
- zend_print_variable(&z_copy);
- zval_dtor(&z_copy);
+ Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL) {
+ if (IS_TMP_VAR == IS_TMP_VAR) {
+ INIT_PZVAL(z);
+ }
+ if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
+ zend_print_variable(&z_copy);
+ zval_dtor(&z_copy);
+ } else {
+ zend_print_variable(z);
+ }
} else {
zend_print_variable(z);
}
zval *z = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
if (IS_VAR != IS_CONST &&
- Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
- zend_print_variable(&z_copy);
- zval_dtor(&z_copy);
+ Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL) {
+ if (IS_VAR == IS_TMP_VAR) {
+ INIT_PZVAL(z);
+ }
+ if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
+ zend_print_variable(&z_copy);
+ zval_dtor(&z_copy);
+ } else {
+ zend_print_variable(z);
+ }
} else {
zend_print_variable(z);
}
zval *z = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
if (IS_CV != IS_CONST &&
- Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL &&
- zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
- zend_print_variable(&z_copy);
- zval_dtor(&z_copy);
+ Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL) {
+ if (IS_CV == IS_TMP_VAR) {
+ INIT_PZVAL(z);
+ }
+ if (zend_std_cast_object_tostring(z, &z_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
+ zend_print_variable(&z_copy);
+ zval_dtor(&z_copy);
+ } else {
+ zend_print_variable(z);
+ }
} else {
zend_print_variable(z);
}