com php-src: Fix segfault with scalar passed to typehint with not loaded class: Zend/tests/typehints/inexistent_class_hint_with_ scalar_arg.phpt
Zend/zend_execute.c

From: Date: Sat, 20 Jun 2015 23:35:22 +0000
Subject: com php-src: Fix segfault with scalar passed to typehint with not loaded class: Zend/tests/typehints/inexistent_class_hint_with_ scalar_arg.phpt
Zend/zend_execute.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87417@lists.php.net to get a copy of this message
Commit: 115e9288bbd28f7ad525ebcc0053908464be5c95 Author: Bob Weinand <bobwei9@hotmail.com> Sun, 21 Jun 2015 01:35:22 +0200 Parents: f58ebb36094e6c59d4e87bfba2a0504858adbec9 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=115e9288bbd28f7ad525ebcc0053908464be5c95 Log: Fix segfault with scalar passed to typehint with not loaded class Changed paths: A Zend/tests/typehints/inexistent_class_hint_with_scalar_arg.phpt M Zend/zend_execute.c Diff: diff --git a/Zend/tests/typehints/inexistent_class_hint_with_scalar_arg.phpt b/Zend/tests/typehints/inexistent_class_hint_with_scalar_arg.phpt new file mode 100644 index 0000000..3bacf82 --- /dev/null +++ b/Zend/tests/typehints/inexistent_class_hint_with_scalar_arg.phpt @@ -0,0 +1,16 @@ +--TEST-- +Inexistent class as typehint receiving scalar argument +--FILE-- +<?php + +function foo(bar $ex) {} +foo(null); + +?> +--EXPECTF-- +Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be an instance of bar, null given, called in %s on line %d and defined in %s:%d +Stack trace: +#0 %s(%d): foo(NULL) +#1 {main} + thrown in %s on line %d + diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 491dbb8..246372f 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -780,7 +780,11 @@ static zend_always_inline int zend_verify_arg_type(zend_function *zf, uint32_t a } else { ce = zend_verify_arg_class_kind(cur_arg_info); if (UNEXPECTED(!ce)) { - zend_verify_arg_error(zf, arg_num, "be an instance of ", cur_arg_info->class_name->val, "instance of ", Z_OBJCE_P(arg)->name->val, arg); + if (Z_TYPE_P(arg) == IS_OBJECT) { + zend_verify_arg_error(zf, arg_num, "be an instance of ", cur_arg_info->class_name->val, "instance of ", Z_OBJCE_P(arg)->name->val, arg); + } else { + zend_verify_arg_error(zf, arg_num, "be an instance of ", cur_arg_info->class_name->val, "", zend_zval_type_name(arg), arg); + } return 0; } *cache_slot = (void*)ce;

« previous php.cvs (#87417) next »