]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 9 Jun 2020 13:52:48 +0000 (15:52 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 9 Jun 2020 13:52:48 +0000 (15:52 +0200)
* PHP-7.4:
  Fixed bug #79683

1  2 
Zend/zend_object_handlers.c

index 81a1b7b776b29c6ae3eec4ac8a0f30530959abf7,5be63b4cd7b7ac2082978d03803c503ca3e336ce..4a8b24233aa42b978a89db94d7806428a4613448
@@@ -1793,16 -1787,19 +1793,19 @@@ ZEND_API zend_string *zend_std_get_clas
  }
  /* }}} */
  
 -ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type) /* {{{ */
 +ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */
  {
 -      zval retval;
 -      zend_class_entry *ce;
 -
        switch (type) {
 -              case IS_STRING:
 -                      ce = Z_OBJCE_P(readobj);
 +              case IS_STRING: {
 +                      zend_class_entry *ce = readobj->ce;
                        if (ce->__tostring) {
 +                              zval retval;
+                               zend_class_entry *fake_scope = EG(fake_scope);
+                               EG(fake_scope) = NULL;
 +                              GC_ADDREF(readobj);
                                zend_call_method_with_0_params(readobj, ce, &ce->__tostring, "__tostring", &retval);
 +                              zend_object_release(readobj);
+                               EG(fake_scope) = fake_scope;
                                if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {
                                        ZVAL_COPY_VALUE(writeobj, &retval);
                                        return SUCCESS;