From b9ab70c0d24ee9da0db69fe306c16af113f1f7aa Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Mon, 11 Aug 2008 22:08:58 +0000 Subject: [PATCH] - Fixed segmentation fault (test added) --- ext/reflection/php_reflection.c | 2 +- ...nParameter_invalidMethodInConstructor.phpt | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 2e0a9e97f8..d2b3bc5aef 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1871,7 +1871,7 @@ ZEND_METHOD(reflection_parameter, __construct) if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) { efree(lcname); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Method %s::%s() does not exist", Z_STRVAL_PP(classref), Z_TYPE_PP(method), Z_STRVAL_PP(method)); + "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method)); return; } efree(lcname); diff --git a/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt new file mode 100644 index 0000000000..3118c17be8 --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt @@ -0,0 +1,31 @@ +--TEST-- +ReflectionParameter::__construct(): Invalid method as constructor +--FILE-- +getMessage ()."\n"; } + +// Invalid class method +try { + new ReflectionParameter (array ('C', 'b'), 0); +} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } + +// Invalid object method +try { + new ReflectionParameter (array (new C, 'b'), 0); +} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } + +echo "Done.\n"; + +class C { +} + +?> +--EXPECTF-- +Class A does not exist +Method C::b() does not exist +Method C::b() does not exist +Done. -- 2.50.1