]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.3' into PHP-7.4
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 9 May 2019 10:36:20 +0000 (12:36 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 9 May 2019 10:36:20 +0000 (12:36 +0200)
1  2 
ext/reflection/php_reflection.c

index da459e60be0204cc5f4ce13b529927108c80c5f7,c38160297d400447b1b12d5ace6ac3152db864c3..f1037ef6945bdac00b06d6f49a9d83cd946ccdc4
@@@ -4137,15 -4193,24 +4128,26 @@@ ZEND_METHOD(reflection_class, getMethod
        GET_REFLECTION_OBJECT_PTR(ce);
  
        array_init(return_value);
 -      zend_hash_apply_with_arguments(&ce->function_table, (apply_func_args_t) _addmethod_va, 4, &ce, return_value, filter);
 +      ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) {
-               _addmethod(mptr, ce, return_value, filter, &intern->obj);
++              _addmethod(mptr, ce, return_value, filter);
 +      } ZEND_HASH_FOREACH_END();
  
-       if (Z_TYPE(intern->obj) != IS_UNDEF && instanceof_function(ce, zend_ce_closure)) {
-               zend_function *closure = zend_get_closure_invoke_method(Z_OBJ(intern->obj));
+       if (instanceof_function(ce, zend_ce_closure)) {
+               zend_bool has_obj = Z_TYPE(intern->obj) != IS_UNDEF;
+               zval obj_tmp;
+               zend_object *obj;
+               if (!has_obj) {
+                       object_init_ex(&obj_tmp, ce);
+                       obj = Z_OBJ(obj_tmp);
+               } else {
+                       obj = Z_OBJ(intern->obj);
+               }
+               zend_function *closure = zend_get_closure_invoke_method(obj);
                if (closure) {
-                       _addmethod(closure, ce, return_value, filter, &intern->obj);
-                       _free_function(closure);
+                       _addmethod(closure, ce, return_value, filter);
+               }
+               if (!has_obj) {
+                       zval_ptr_dtor(&obj_tmp);
                }
        }
  }