diff options
| author | Remi Collet <remi@php.net> | 2017-06-26 17:22:01 +0200 |
|---|---|---|
| committer | Remi Collet <remi@php.net> | 2017-06-26 17:22:01 +0200 |
| commit | 85c32322acfc07628140bf631e7c52b12e6050b4 (patch) | |
| tree | ae79035283e68957177407123d7d342278e021d9 | |
| parent | 4ed8ff509001b35e0cb971a1d6a294345c5d7673 (diff) | |
| parent | caaeb4849aa56cbbdc66ea015c11a58bd47a43ff (diff) | |
| download | php-git-85c32322acfc07628140bf631e7c52b12e6050b4.tar.gz | |
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: (24 commits)
Removed EG(valid_symbol_table). Used EG(active) instead.
Release temporary string reference
Remove superfluous semicolons
Fix tests on Windows
Produce a better exception message when IntlDateFormatter constructor fails.
Fix format arguments
Remove unused variable op2. It is redeclared later.
Fix typo
Implement object type annotation
Fixed bug #73173
Expose inflate_get_status() and inflate_get_read_len() functions
Add more constants, improve comments, and add tests
Fixed bug #73900
Add OPENSSL_DONT_ZERO_PAD_KEY constant to prevent key padding
Drop soap_hash_str_find_deref()
Only compute callback name in error cases
Extract zend_get_callable_name() API
Move va_copy compatibility code into zend_portability.h
Remove unnecessary string copy
Fix FE_FETCH_* exception check
...
117 files changed, 1135 insertions, 534 deletions
@@ -8,6 +8,7 @@ PHP NEWS . Fixed bug #74761 (Unary operator expected error on some systems). (petk) . Allow loading PHP/Zend extensions by name in ini files (extension=<name>). (francois at tekwire dot net) + . Added object type annotation. (brzuchal) - OpenSSL: . Fixed bug #74798 (pkcs7_en/decrypt does not work if \x0a is used in content). @@ -20,6 +21,12 @@ PHP NEWS . Add support for extension name as argument to dl(). (francois at tekwire dot net) +- zlib: + . Fixed bug #73944 (dictionary option of inflate_init() does not work). + (wapmorgan) + . Expose inflate_get_status() and inflate_get_read_len() functions. + (Matthew Trescott) + 22 Jun 2017, PHP 7.2.0alpha2 - Core: @@ -41,6 +41,7 @@ PHP 7.2 UPGRADE NOTES . Minimum supported Windows versions are Windows 7/Server 2008 R2. . Initial trait property value compatibility check will no longer perform any casts. (Bug #74269) + . "object" (in any case) can no longer be used as a class name. - BCMath: . The bcmod() function no longer truncates fractional numbers to integers. As @@ -101,6 +102,8 @@ PHP 7.2 UPGRADE NOTES (https://wiki.php.net/rfc/allow-abstract-function-override) . A trailing comma in group use statements is now allowed. (https://wiki.php.net/rfc/list-syntax-trailing-commas) + . The "object" type annotation is now supported. + (https://wiki.php.net/rfc/object-typehint) - DBA: . Implemented support for the LMDB backend. diff --git a/Zend/tests/bug26698.phpt b/Zend/tests/bug26698.phpt index aecc708a0d..a4d6ad13f8 100644 --- a/Zend/tests/bug26698.phpt +++ b/Zend/tests/bug26698.phpt @@ -5,7 +5,7 @@ Bug #26698 (Thrown exceptions while evaluting argument to pass as parameter cras ini_set("report_memleaks", 0); // the exception thrown in this test results in a memory leak, which is fine -class Object +class ObjectOne { function getNone() { @@ -23,7 +23,7 @@ class Proxy { try { - $res = new Object(); + $res = new ObjectOne(); $this->three($res->getNone()); } catch(Exception $e) @@ -36,7 +36,7 @@ class Proxy { try { - $res = new Object(); + $res = new ObjectOne(); $this->three(1, $res->getNone()); } catch(Exception $e) @@ -49,7 +49,7 @@ class Proxy { try { - $res = new Object(); + $res = new ObjectOne(); $this->three(1, 2, $res->getNone()); } catch(Exception $e) diff --git a/Zend/tests/bug28444.phpt b/Zend/tests/bug28444.phpt index 78c08d2fc6..b7e863da92 100644 --- a/Zend/tests/bug28444.phpt +++ b/Zend/tests/bug28444.phpt @@ -9,7 +9,7 @@ function my_error_handler($errno, $errstr, $errfile, $errline) { set_error_handler('my_error_handler'); -class Object +class ObjectOne { public $x; @@ -26,7 +26,7 @@ class Overloaded function __construct($x) { - $this->x = new Object($x); + $this->x = new ObjectOne($x); } function __get($prop) @@ -47,7 +47,7 @@ var_dump($y->x->x); var_dump($y->x->x = 3); var_dump($y->y = 3); var_dump($y->y); -var_dump($y->z = new Object(4)); +var_dump($y->z = new ObjectOne(4)); var_dump($y->z->x); $t = $y->z; var_dump($t->x = 5); @@ -56,7 +56,7 @@ var_dump($y->z->x = 6); ?> ===DONE=== --EXPECTF-- -object(Object)#%d (1) { +object(ObjectOne)#%d (1) { ["x"]=> int(2) } @@ -66,9 +66,9 @@ Overloaded::__set(y,3) int(3) Overloaded::__get(y) int(3) -string(55) "Object of class Object could not be converted to string" +string(58) "Object of class ObjectOne could not be converted to string" Overloaded::__set(z,) -object(Object)#%d (1) { +object(ObjectOne)#%d (1) { ["x"]=> int(4) } diff --git a/Zend/tests/bug35470.phpt b/Zend/tests/bug35470.phpt index 5a854552bb..01d045744a 100644 --- a/Zend/tests/bug35470.phpt +++ b/Zend/tests/bug35470.phpt @@ -5,7 +5,7 @@ Bug #35470 (Assigning global using variable name from array doesn't function) $x = array("test", "55"); global ${$x[0]}; ${$x[0]} = $x[1]; -echo "Test: $test\n";; +echo "Test: $test\n"; ?> --EXPECT-- Test: 55 diff --git a/Zend/tests/bug49893.phpt b/Zend/tests/bug49893.phpt index b340f7bdfd..addf447073 100644 --- a/Zend/tests/bug49893.phpt +++ b/Zend/tests/bug49893.phpt @@ -20,7 +20,7 @@ class B { try { $b = new B(); } catch(Exception $e) { - echo $e->getMessage() . "\n";; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug60598.phpt b/Zend/tests/bug60598.phpt index eeee75a19d..143ac79504 100644 --- a/Zend/tests/bug60598.phpt +++ b/Zend/tests/bug60598.phpt @@ -6,7 +6,7 @@ define('OBJECT_COUNT', 10000); $containers = array(); -class Object { +class ObjectOne { protected $_guid = 0; public function __construct() { global $containers; @@ -20,7 +20,7 @@ class Object { } for ($i = 0; $i < OBJECT_COUNT; ++$i) { - new Object(); + new ObjectOne(); } // You probably won't see this because of the "zend_mm_heap corrupted" diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt index 1b4c35d65f..f793e70781 100644 --- a/Zend/tests/bug70547.phpt +++ b/Zend/tests/bug70547.phpt @@ -53,27 +53,43 @@ string(3) "1st" string(3) "2nd" NULL string(3) "4th" -array(3) { +array(4) { [0]=> string(3) "1st" [1]=> &string(3) "2nd" + [2]=> + NULL [3]=> string(3) "4th" } -array(2) { +array(4) { + [0]=> + NULL [1]=> string(3) "2nd" + [2]=> + NULL [3]=> string(3) "4th" } -array(2) { +array(4) { + [0]=> + NULL [1]=> &string(3) "2nd" + [2]=> + NULL [3]=> string(3) "4th" } -array(1) { +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL [3]=> string(3) "4th" } diff --git a/Zend/tests/bug73900.phpt b/Zend/tests/bug73900.phpt new file mode 100644 index 0000000000..fbd5b8604a --- /dev/null +++ b/Zend/tests/bug73900.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #73900: Use After Free in unserialize() SplFixedArray +--FILE-- +<?php + +$a = new stdClass; +$b = new SplFixedArray(1); +$b[0] = $a; +$c = &$b[0]; +var_dump($c); + +?> +--EXPECT-- +object(stdClass)#1 (0) { +} diff --git a/Zend/tests/bug74810.phpt b/Zend/tests/bug74810.phpt new file mode 100644 index 0000000000..6c24e4bce8 --- /dev/null +++ b/Zend/tests/bug74810.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #74810: Something odd about ordering of func_get_args() result in 7.2 +--FILE-- +<?php + +function test_slice1() { + var_dump(array_slice(func_get_args(), 1)); +} +function test_slice5() { + var_dump(array_slice(func_get_args(), 5)); +} + +test_slice1(1, 2, 3); +test_slice5(1, 2, 3); + +?> +--EXPECT-- +array(2) { + [0]=> + int(2) + [1]=> + int(3) +} +array(0) { +} diff --git a/Zend/tests/fe_fetch_dtor_exception.phpt b/Zend/tests/fe_fetch_dtor_exception.phpt new file mode 100644 index 0000000000..840544b8ec --- /dev/null +++ b/Zend/tests/fe_fetch_dtor_exception.phpt @@ -0,0 +1,22 @@ +--TEST-- +Dtor may throw exception furing FE_FETCH assignment +--FILE-- +<?php + +$v = new class { + function __destruct() { + throw new Exception("foo"); + } +}; + +try { + foreach ([1, 2] as $v) { + var_dump($v); + } +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +foo diff --git a/Zend/tests/object_types/invalid_default_value.phpt b/Zend/tests/object_types/invalid_default_value.phpt new file mode 100644 index 0000000000..2768e00e7d --- /dev/null +++ b/Zend/tests/object_types/invalid_default_value.phpt @@ -0,0 +1,10 @@ +--TEST-- +Object type can only default to null +--FILE-- +<?php + +function test(object $obj = 42) { } + +?> +--EXPECTF-- +Fatal error: Default value for parameters with an object type can only be NULL in %s on line %d diff --git a/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt b/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt new file mode 100644 index 0000000000..138ae1f5b5 --- /dev/null +++ b/Zend/tests/object_types/missing_return_type_inheritance_in_class.phpt @@ -0,0 +1,15 @@ +--TEST-- +Missing class method a object return type during inheritance +--FILE-- +<?php + +class One { + public function a() : object {} +} + +class Two extends One { + public function a() {} +} + +--EXPECTF-- +Fatal error: Declaration of Two::a() must be compatible with One::a(): object in %s on line 9
\ No newline at end of file diff --git a/Zend/tests/object_types/missing_return_type_inheritance_in_interface.phpt b/Zend/tests/object_types/missing_return_type_inheritance_in_interface.phpt new file mode 100644 index 0000000000..af9032949c --- /dev/null +++ b/Zend/tests/object_types/missing_return_type_inheritance_in_interface.phpt @@ -0,0 +1,15 @@ +--TEST-- +Missing interface method a object return type during inheritance +--FILE-- +<?php + +interface One { + public function a() : object; +} + +interface Two extends One { + public function a(); +} + +--EXPECTF-- +Fatal error: Declaration of Two::a() must be compatible with One::a(): object in %s on line %d diff --git a/Zend/tests/object_types/return_type_in_class.phpt b/Zend/tests/object_types/return_type_in_class.phpt new file mode 100644 index 0000000000..2d0f771106 --- /dev/null +++ b/Zend/tests/object_types/return_type_in_class.phpt @@ -0,0 +1,26 @@ +--TEST-- +Adding a class method object return type +--FILE-- +<?php + +interface One { + public function a() : object; +} + +class Two implements One { + public function a() : object {} +} + +$three = new class extends Two { + public function a() : object { + return 12345; + } +}; +$three->a(); +--EXPECTF-- + +Fatal error: Uncaught TypeError: Return value of class@anonymous::a() must be an object, integer returned in %s:13 +Stack trace: +#0 %s(16): class@anonymous->a() +#1 {main} + thrown in %s on line 13 diff --git a/Zend/tests/object_types/return_type_in_function.phpt b/Zend/tests/object_types/return_type_in_function.phpt new file mode 100644 index 0000000000..e8ae75f490 --- /dev/null +++ b/Zend/tests/object_types/return_type_in_function.phpt @@ -0,0 +1,16 @@ +--TEST-- +Adding a function object return type +--FILE-- +<?php + +function a() : object { + return 12345; +} +a(); +--EXPECTF-- + +Fatal error: Uncaught TypeError: Return value of a() must be an object, integer returned in %s:4 +Stack trace: +#0 %s(6): a() +#1 {main} + thrown in %s on line 4
\ No newline at end of file diff --git a/Zend/tests/object_types/return_type_inheritance_in_class.phpt b/Zend/tests/object_types/return_type_inheritance_in_class.phpt new file mode 100644 index 0000000000..826758f326 --- /dev/null +++ b/Zend/tests/object_types/return_type_inheritance_in_class.phpt @@ -0,0 +1,26 @@ +--TEST-- +Adding class method a object return type during inheritance is allowed +--FILE-- +<?php + +class One { + public function a() {} +} + +class Two extends One { + public function a() : object {} +} + +$three = new class extends Two { + public function a() : object { + return 12345; + } +}; +$three->a(); + +--EXPECTF-- +Fatal error: Uncaught TypeError: Return value of class@anonymous::a() must be an object, integer returned in %s:13 +Stack trace: +#0 %s(16): class@anonymous->a() +#1 {main} + thrown in %s on line 13 diff --git a/Zend/tests/object_types/return_type_inheritance_in_interface.phpt b/Zend/tests/object_types/return_type_inheritance_in_interface.phpt new file mode 100644 index 0000000000..fe1f6e6c0c --- /dev/null +++ b/Zend/tests/object_types/return_type_inheritance_in_interface.phpt @@ -0,0 +1,26 @@ +--TEST-- +Adding interface method a object return type during inheritance is allowed +--FILE-- +<?php + +interface One { + public function a(); +} + +interface Two extends One { + public function a() : object; +} + +$three = new class implements Two { + public function a() : object { + return 12345; + } +}; +$three->a(); + +--EXPECTF-- +Fatal error: Uncaught TypeError: Return value of class@anonymous::a() must be an object, integer returned in %s:13 +Stack trace: +#0 %s(16): class@anonymous->a() +#1 {main} + thrown in %s on line 13 diff --git a/Zend/tests/object_types/return_type_reflection.phpt b/Zend/tests/object_types/return_type_reflection.phpt new file mode 100644 index 0000000000..461199febe --- /dev/null +++ b/Zend/tests/object_types/return_type_reflection.phpt @@ -0,0 +1,31 @@ +--TEST-- +Reflecting object return type +--FILE-- +<?php + +interface One { + public function a() : object; +} + +class Two implements One { + public function a() : object {} +} + +function a() : object {} + +$returnTypeOne = (new ReflectionClass(One::class))->getMethod('a')->getReturnType(); +var_dump($returnTypeOne->isBuiltin(), (string)$returnTypeOne); + +$returnTypeTwo = (new ReflectionClass(Two::class))->getMethod('a')->getReturnType(); +var_dump($returnTypeTwo->isBuiltin(), (string)$returnTypeTwo); + +$returnTypea = (new ReflectionFunction('a'))->getReturnType(); +var_dump($returnTypea->isBuiltin(), (string)$returnTypea); + +--EXPECTF-- +bool(true) +string(6) "object" +bool(true) +string(6) "object" +bool(true) +string(6) "object"
\ No newline at end of file diff --git a/Zend/tests/object_types/type_hint_in_class_method.phpt b/Zend/tests/object_types/type_hint_in_class_method.phpt new file mode 100644 index 0000000000..e41caa0e70 --- /dev/null +++ b/Zend/tests/object_types/type_hint_in_class_method.phpt @@ -0,0 +1,19 @@ +--TEST-- +Adding a class method object type hint +--FILE-- +<?php + +class One { + public function a(object $obj) {} +} + +$one = new One(); +$one->a(new One()); +$one->a(123); +--EXPECTF-- + +Fatal error: Uncaught TypeError: Argument 1 passed to One::a() must be an object, integer given, called in %s:4 +Stack trace: +#0 %s(9): One->a(123) +#1 {main} + thrown in %s on line 4
\ No newline at end of file diff --git a/Zend/tests/object_types/type_hint_in_function.phpt b/Zend/tests/object_types/type_hint_in_function.phpt new file mode 100644 index 0000000000..917726ce2e --- /dev/null +++ b/Zend/tests/object_types/type_hint_in_function.phpt @@ -0,0 +1,17 @@ +--TEST-- +Adding a function object type hint +--FILE-- +<?php + +class A {} +function a(object $obj) {} + +a(new A()); +a(123); +--EXPECTF-- + +Fatal error: Uncaught TypeError: Argument 1 passed to a() must be an object, integer given, called in %s.php on line 7 and defined in %s:4 +Stack trace: +#0 %s(7): a(123) +#1 {main} + thrown in %s on line 4
\ No newline at end of file diff --git a/Zend/tests/object_types/type_hint_reflection.phpt b/Zend/tests/object_types/type_hint_reflection.phpt new file mode 100644 index 0000000000..8968e35d6c --- /dev/null +++ b/Zend/tests/object_types/type_hint_reflection.phpt @@ -0,0 +1,31 @@ +--TEST-- +Reflecting object type hint +--FILE-- +<?php + +interface One { + public function a(object $obj); +} + +class Two implements One { + public function a(object $obj) {} +} + +function a(object $obj) {} + +$typeHintOne = (new ReflectionClass(One::class))->getMethod('a')->getParameters()[0]->getType(); +var_dump($typeHintOne->isBuiltin(), (string)$typeHintOne); + +$typeHintTwo = (new ReflectionClass(Two::class))->getMethod('a')->getParameters()[0]->getType(); +var_dump($typeHintTwo->isBuiltin(), (string)$typeHintTwo); + +$typeHinta = (new ReflectionFunction('a'))->getParameters()[0]->getType(); +var_dump($typeHinta->isBuiltin(), (string)$typeHinta); + +--EXPECTF-- +bool(true) +string(6) "object" +bool(true) +string(6) "object" +bool(true) +string(6) "object"
\ No newline at end of file diff --git a/Zend/zend.c b/Zend/zend.c index a5434c2e5e..0cb0cc7d41 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -638,7 +638,6 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{ zend_get_windows_version_info(&executor_globals->windows_version_info); #endif executor_globals->flags = EG_FLAGS_INITIAL; - executor_globals->valid_symbol_table = 0; } /* }}} */ @@ -1102,8 +1101,6 @@ ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) /* {{{ */ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list args) #endif { - char *str; - int len; #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS) va_list args; #endif @@ -1232,24 +1229,9 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a break; default: /* Handle the error in user space */ -/* va_copy() is __va_copy() in old gcc versions. - * According to the autoconf manual, using - * memcpy(&dst, &src, sizeof(va_list)) - * gives maximum portability. */ -#ifndef va_copy -# ifdef __va_copy -# define va_copy(dest, src) __va_copy((dest), (src)) -# else -# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list)) -# endif -#endif va_copy(usr_copy, args); - len = (int)zend_vspprintf(&str, 0, format, usr_copy); - ZVAL_NEW_STR(¶ms[1], zend_string_init(str, len, 0)); - efree(str); -#ifdef va_copy + ZVAL_STR(¶ms[1], zend_vstrpprintf(0, format, usr_copy)); va_end(usr_copy); -#endif ZVAL_LONG(¶ms[0], type); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index fef56750a2..bf2619e8e2 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3241,14 +3241,86 @@ get_function_via_handler: } /* }}} */ -ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error) /* {{{ */ +static zend_string *zend_create_method_string(zend_string *class_name, zend_string *method_name) { + zend_string *callable_name = zend_string_alloc( + ZSTR_LEN(class_name) + ZSTR_LEN(method_name) + sizeof("::") - 1, 0); + char *ptr = ZSTR_VAL(callable_name); + memcpy(ptr, ZSTR_VAL(class_name), ZSTR_LEN(class_name)); + ptr += ZSTR_LEN(class_name); + memcpy(ptr, "::", sizeof("::") - 1); + ptr += sizeof("::") - 1; + memcpy(ptr, ZSTR_VAL(method_name), ZSTR_LEN(method_name) + 1); + return callable_name; +} + +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object) /* {{{ */ +{ +try_again: + switch (Z_TYPE_P(callable)) { + case IS_STRING: + if (object) { + return zend_create_method_string(object->ce->name, Z_STR_P(callable)); + } + return zend_string_copy(Z_STR_P(callable)); + + case IS_ARRAY: + { + zval *method = NULL; + zval *obj = NULL; + + if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) { + obj = zend_hash_index_find_deref(Z_ARRVAL_P(callable), 0); + method = zend_hash_index_find_deref(Z_ARRVAL_P(callable), 1); + } + + if (obj == NULL || method == NULL || Z_TYPE_P(method) != IS_STRING) { + return zend_string_init("Array", sizeof("Array")-1, 0); + } + + if (Z_TYPE_P(obj) == IS_STRING) { + return zend_create_method_string(Z_STR_P(obj), Z_STR_P(method)); + } else if (Z_TYPE_P(obj) == IS_OBJECT) { + return zend_create_method_string(Z_OBJCE_P(obj)->name, Z_STR_P(method)); + } else { + return zend_string_init("Array", sizeof("Array")-1, 0); + } + } + case IS_OBJECT: + { + zend_class_entry *calling_scope; + zend_function *fptr; + zend_object *object; + if (Z_OBJ_HANDLER_P(callable, get_closure) + && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &calling_scope, &fptr, &object) == SUCCESS) { + zend_class_entry *ce = Z_OBJCE_P(callable); + zend_string *callable_name = zend_string_alloc( + ZSTR_LEN(ce->name) + sizeof("::__invoke") - 1, 0); + memcpy(ZSTR_VAL(callable_name), ZSTR_VAL(ce->name), ZSTR_LEN(ce->name)); + memcpy(ZSTR_VAL(callable_name) + ZSTR_LEN(ce->name), "::__invoke", sizeof("::__invoke")); + return callable_name; + } + return zval_get_string(callable); + } + case IS_REFERENCE: + callable = Z_REFVAL_P(callable); + goto try_again; + default: + return zval_get_string(callable); + } +} +/* }}} */ + +ZEND_API zend_string *zend_get_callable_name(zval *callable) /* {{{ */ +{ + return zend_get_callable_name_ex(callable, NULL); +} +/* }}} */ + +static zend_bool zend_is_callable_impl(zval *callable, zend_object *object, uint32_t check_flags, zend_fcall_info_cache *fcc, char **error) /* {{{ */ { zend_bool ret; zend_fcall_info_cache fcc_local; - if (callable_name) { - *callable_name = NULL; - } if (fcc == NULL) { fcc = &fcc_local; } @@ -3274,20 +3346,8 @@ again: if (object) { fcc->object = object; fcc->calling_scope = object->ce; - if (callable_name) { - char *ptr; - - *callable_name = zend_string_alloc(ZSTR_LEN(fcc->calling_scope->name) + Z_STRLEN_P(callable) + sizeof("::") - 1, 0); - ptr = ZSTR_VAL(*callable_name); - memcpy(ptr, ZSTR_VAL(fcc->calling_scope->name), ZSTR_LEN(fcc->calling_scope->name)); - ptr += ZSTR_LEN(fcc->calling_scope->name); - memcpy(ptr, "::", sizeof("::") - 1); - ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1); - } - } else if (callable_name) { - *callable_name = zend_string_copy(Z_STR_P(callable)); } + if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { fcc->called_scope = fcc->calling_scope; return 1; @@ -3329,19 +3389,6 @@ again: ZVAL_DEREF(obj); if (Z_TYPE_P(obj) == IS_STRING) { - if (callable_name) { - char *ptr; - - - *callable_name = zend_string_alloc(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0); - ptr = ZSTR_VAL(*callable_name); - memcpy(ptr, Z_STRVAL_P(obj), Z_STRLEN_P(obj)); - ptr += Z_STRLEN_P(obj); - memcpy(ptr, "::", sizeof("::") - 1); - ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); - } - if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { return 1; } @@ -3360,18 +3407,6 @@ again: fcc->object = Z_OBJ_P(obj); - if (callable_name) { - char *ptr; - - *callable_name = zend_string_alloc(ZSTR_LEN(fcc->calling_scope->name) + Z_STRLEN_P(method) + sizeof("::") - 1, 0); - ptr = ZSTR_VAL(*callable_name); - memcpy(ptr, ZSTR_VAL(fcc->calling_scope->name), ZSTR_LEN(fcc->calling_scope->name)); - ptr += ZSTR_LEN(fcc->calling_scope->name); - memcpy(ptr, "::", sizeof("::") - 1); - ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); - } - if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { fcc->called_scope = fcc->calling_scope; return 1; @@ -3405,42 +3440,35 @@ again: } else { if (error) zend_spprintf(error, 0, "array must have exactly two members"); } - if (callable_name) { - *callable_name = zend_string_init("Array", sizeof("Array")-1, 0); - } } return 0; case IS_OBJECT: if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { fcc->called_scope = fcc->calling_scope; - if (callable_name) { - zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */ - - *callable_name = zend_string_alloc(ZSTR_LEN(ce->name) + sizeof("::__invoke") - 1, 0); - memcpy(ZSTR_VAL(*callable_name), ZSTR_VAL(ce->name), ZSTR_LEN(ce->name)); - memcpy(ZSTR_VAL(*callable_name) + ZSTR_LEN(ce->name), "::__invoke", sizeof("::__invoke")); - } fcc->initialized = 1; return 1; } - if (callable_name) { - *callable_name = zval_get_string(callable); - } if (error) zend_spprintf(error, 0, "no array or string given"); return 0; case IS_REFERENCE: callable = Z_REFVAL_P(callable); goto again; default: - if (callable_name) { - *callable_name = zval_get_string(callable); - } if (error) zend_spprintf(error, 0, "no array or string given"); return 0; } } /* }}} */ +ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error) /* {{{ */ +{ + zend_bool ret = zend_is_callable_impl(callable, object, check_flags, fcc, error); + if (callable_name) { + *callable_name = zend_get_callable_name_ex(callable, object); + } + return ret; +} + ZEND_API zend_bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name) /* {{{ */ { return zend_is_callable_ex(callable, NULL, check_flags, callable_name, NULL, NULL); diff --git a/Zend/zend_API.h b/Zend/zend_API.h index df04be1fbe..4ce6d91b87 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -323,6 +323,8 @@ ZEND_API ZEND_COLD void zend_wrong_param_count(void); #define IS_CALLABLE_STRICT (IS_CALLABLE_CHECK_IS_STATIC) +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object); +ZEND_API zend_string *zend_get_callable_name(zval *callable); ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error); ZEND_API zend_bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name); ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name); diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 678c852e8b..70613b2b96 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1880,7 +1880,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap) if (free_counter == bin_elements[i]) { has_free_pages = 1; } - chunk->map[page_num] = ZEND_MM_SRUN_EX(i, free_counter);; + chunk->map[page_num] = ZEND_MM_SRUN_EX(i, free_counter); p = p->next_free_slot; } @@ -1907,7 +1907,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap) ZEND_ASSERT(ZEND_MM_SRUN_BIN_NUM(info) == i); if (ZEND_MM_SRUN_FREE_COUNTER(info) == bin_elements[i]) { /* remove from cache */ - p = p->next_free_slot;; + p = p->next_free_slot; *q = p; } else { q = &p->next_free_slot; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 960a1debef..150603f879 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -454,7 +454,7 @@ ZEND_FUNCTION(func_get_args) { zval *p, *q; uint32_t arg_count, first_extra_arg; - uint32_t i, n; + uint32_t i; zend_execute_data *ex = EX(prev_execute_data); if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) { @@ -474,7 +474,6 @@ ZEND_FUNCTION(func_get_args) zend_hash_real_init(Z_ARRVAL_P(return_value), 1); ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { i = 0; - n = 0; p = ZEND_CALL_ARG(ex, 1); if (arg_count > first_extra_arg) { while (i < first_extra_arg) { @@ -484,7 +483,8 @@ ZEND_FUNCTION(func_get_args) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; @@ -499,14 +499,15 @@ ZEND_FUNCTION(func_get_args) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } } ZEND_HASH_FILL_END(); - Z_ARRVAL_P(return_value)->nNumOfElements = n; + Z_ARRVAL_P(return_value)->nNumOfElements = arg_count; } } /* }}} */ @@ -1592,7 +1593,6 @@ ZEND_FUNCTION(trigger_error) ZEND_FUNCTION(set_error_handler) { zval *error_handler; - zend_string *error_handler_name = NULL; zend_long error_type = E_ALL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|l", &error_handler, &error_type) == FAILURE) { @@ -1600,13 +1600,13 @@ ZEND_FUNCTION(set_error_handler) } if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */ - if (!zend_is_callable(error_handler, 0, &error_handler_name)) { + if (!zend_is_callable(error_handler, 0, NULL)) { + zend_string *error_handler_name = zend_get_callable_name(error_handler); zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", get_active_function_name(), error_handler_name?ZSTR_VAL(error_handler_name):"unknown"); zend_string_release(error_handler_name); return; } - zend_string_release(error_handler_name); } if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { @@ -1661,20 +1661,19 @@ ZEND_FUNCTION(restore_error_handler) ZEND_FUNCTION(set_exception_handler) { zval *exception_handler; - zend_string *exception_handler_name = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &exception_handler) == FAILURE) { return; } if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */ - if (!zend_is_callable(exception_handler, 0, &exception_handler_name)) { + if (!zend_is_callable(exception_handler, 0, NULL)) { + zend_string *exception_handler_name = zend_get_callable_name(exception_handler); zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", get_active_function_name(), exception_handler_name?ZSTR_VAL(exception_handler_name):"unknown"); zend_string_release(exception_handler_name); return; } - zend_string_release(exception_handler_name); } if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { @@ -2122,7 +2121,6 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / array_init_size(arg_array, num_args); if (num_args) { uint32_t i = 0; - uint32_t n = 0; zval *p = ZEND_CALL_ARG(call, 1); zend_hash_real_init(Z_ARRVAL_P(arg_array), 1); @@ -2145,12 +2143,9 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg); } - n++; ZEND_HASH_FILL_ADD(arg); } else { - zval tmp; - ZVAL_UNDEF(&tmp); - ZEND_HASH_FILL_ADD(&tmp); + ZEND_HASH_FILL_ADD(&EG(uninitialized_zval)); } i++; } @@ -2160,9 +2155,10 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } - n++; + ZEND_HASH_FILL_ADD(p); + } else { + ZEND_HASH_FILL_ADD(&EG(uninitialized_zval)); } - ZEND_HASH_FILL_ADD(p); p++; i++; } @@ -2175,14 +2171,15 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (Z_OPT_REFCOUNTED_P(p)) { Z_ADDREF_P(p); } - n++; + ZEND_HASH_FILL_ADD(p); + } else { + ZEND_HASH_FILL_ADD(&EG(uninitialized_zval)); } - ZEND_HASH_FILL_ADD(p); p++; i++; } } ZEND_HASH_FILL_END(); - Z_ARRVAL_P(arg_array)->nNumOfElements = n; + Z_ARRVAL_P(arg_array)->nNumOfElements = num_args; } } /* }}} */ diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 309f7005d2..f854631f0b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -162,6 +162,7 @@ static const struct reserved_class_name reserved_class_names[] = { {ZEND_STRL("true")}, {ZEND_STRL("void")}, {ZEND_STRL("iterable")}, + {ZEND_STRL("object")}, {NULL, 0} }; @@ -207,6 +208,7 @@ static const builtin_type_info builtin_types[] = { {ZEND_STRL("bool"), _IS_BOOL}, {ZEND_STRL("void"), IS_VOID}, {ZEND_STRL("iterable"), IS_ITERABLE}, + {ZEND_STRL("object"), IS_OBJECT}, {NULL, 0, IS_UNDEF} }; @@ -5565,6 +5567,11 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ "with iterable type can only be an array or NULL"); } break; + + case IS_OBJECT: + zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " + "with an object type can only be NULL"); + break; default: if (!ZEND_SAME_FAKE_TYPE(ZEND_TYPE_CODE(arg_info->type), Z_TYPE(default_node.u.constant))) { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 715808632e..3159766bc5 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -648,7 +648,6 @@ static ZEND_COLD void zend_verify_type_error_common( { zend_bool is_interface = 0; *fname = ZSTR_VAL(zf->common.function_name); - if (zf->common.scope) { *fsep = "::"; *fclass = ZSTR_VAL(zf->common.scope->name); @@ -674,6 +673,10 @@ static ZEND_COLD void zend_verify_type_error_common( } } else { switch (ZEND_TYPE_CODE(arg_info->type)) { + case IS_OBJECT: + *need_msg = "be an "; + *need_kind = "object"; + break; case IS_CALLABLE: *need_msg = "be callable"; *need_kind = ""; @@ -1667,16 +1670,9 @@ fetch_from_array: zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ZSTR_VAL(ce->name)); } else if (EXPECTED(retval && Z_TYPE_P(retval) != IS_UNDEF)) { if (!Z_ISREF_P(retval)) { - if (Z_REFCOUNTED_P(retval) && - Z_REFCOUNT_P(retval) > 1) { - if (Z_TYPE_P(retval) != IS_OBJECT) { - Z_DELREF_P(retval); - ZVAL_DUP(result, retval); - retval = result; - } else { - ZVAL_COPY_VALUE(result, retval); - retval = result; - } + if (result != retval) { + ZVAL_COPY(result, retval); + retval = result; } if (Z_TYPE_P(retval) != IS_OBJECT) { zend_class_entry *ce = Z_OBJCE_P(container); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index fec7f73f57..5e02b78af1 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -146,7 +146,6 @@ void init_executor(void) /* {{{ */ zend_vm_stack_init(); zend_hash_init(&EG(symbol_table), 64, NULL, ZVAL_PTR_DTOR, 0); - EG(valid_symbol_table) = 1; zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator); @@ -267,7 +266,6 @@ void shutdown_executor(void) /* {{{ */ /* All resources and objects are destroyed. */ /* No PHP callback functions may be called after this point. */ EG(active) = 0; - EG(valid_symbol_table) = 0; zend_try { zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator); @@ -703,19 +701,18 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } if (!fci_cache || !fci_cache->initialized) { - zend_string *callable_name; char *error = NULL; if (!fci_cache) { fci_cache = &fci_cache_local; } - if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error)) { + if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, NULL, fci_cache, &error)) { if (error) { + zend_string *callable_name + = zend_get_callable_name_ex(&fci->function_name, fci->object); zend_error(E_WARNING, "Invalid callback %s, %s", ZSTR_VAL(callable_name), error); efree(error); - } - if (callable_name) { zend_string_release(callable_name); } if (EG(current_execute_data) == &dummy_execute_data) { @@ -730,16 +727,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / zend_error(E_DEPRECATED, "%s", error); efree(error); if (UNEXPECTED(EG(exception))) { - if (callable_name) { - zend_string_release(callable_name); - } if (EG(current_execute_data) == &dummy_execute_data) { EG(current_execute_data) = dummy_execute_data.prev_execute_data; } return FAILURE; } } - zend_string_release(callable_name); } func = fci_cache->function_handler; @@ -1672,7 +1665,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{ if (force) { zend_array *symbol_table = zend_rebuild_symbol_table(); if (symbol_table) { - return zend_hash_update(symbol_table, name, value) ? SUCCESS : FAILURE;; + return zend_hash_update(symbol_table, name, value) ? SUCCESS : FAILURE; } } } else { @@ -1714,7 +1707,7 @@ ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, i if (force) { zend_array *symbol_table = zend_rebuild_symbol_table(); if (symbol_table) { - return zend_hash_str_update(symbol_table, name, len, value) ? SUCCESS : FAILURE;; + return zend_hash_str_update(symbol_table, name, len, value) ? SUCCESS : FAILURE; } } } else { diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 151f47c71f..c026b30d34 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -208,7 +208,6 @@ struct _zend_executor_globals { struct _zend_module_entry *current_module; zend_bool active; - zend_bool valid_symbol_table; zend_uchar flags; zend_long assertions; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 6b54bda2c7..82e1065303 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -772,6 +772,33 @@ static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht, ze } } +static zend_always_inline zval *zend_hash_index_find_deref(HashTable *ht, zend_ulong h) +{ + zval *zv = zend_hash_index_find(ht, h); + if (zv) { + ZVAL_DEREF(zv); + } + return zv; +} + +static zend_always_inline zval *zend_hash_find_deref(HashTable *ht, zend_string *str) +{ + zval *zv = zend_hash_find(ht, str); + if (zv) { + ZVAL_DEREF(zv); + } + return zv; +} + +static zend_always_inline zval *zend_hash_str_find_deref(HashTable *ht, const char *str, size_t len) +{ + zval *zv = zend_hash_str_find(ht, str, len); + if (zv) { + ZVAL_DEREF(zv); + } + return zv; +} + static zend_always_inline void *zend_symtable_str_find_ptr(HashTable *ht, const char *str, size_t len) { zend_ulong idx; diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index b2b956a82c..eefbd7b821 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -498,6 +498,18 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */ #define ZEND_VALID_SOCKET(sock) ((sock) >= 0) #endif +/* va_copy() is __va_copy() in old gcc versions. + * According to the autoconf manual, using + * memcpy(&dst, &src, sizeof(va_list)) + * gives maximum portability. */ +#ifndef va_copy +# ifdef __va_copy +# define va_copy(dest, src) __va_copy((dest), (src)) +# else +# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list)) +# endif +#endif + #endif /* ZEND_PORTABILITY_H */ /* diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 591387f939..ea568425b2 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4447,7 +4447,7 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY, NUM) { USE_OPLINE zend_free_op free_op1; - zval *args, *op2; + zval *args; SAVE_OPLINE(); args = GET_OP1_ZVAL_PTR(BP_VAR_R); @@ -5954,7 +5954,7 @@ ZEND_VM_C_LABEL(fe_fetch_r_exit): GC_REFCOUNT(gc)++; } } - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR) @@ -6128,7 +6128,7 @@ ZEND_VM_C_LABEL(fe_fetch_w_exit): Z_ADDREF_P(value); ZVAL_REF(EX_VAR(opline->op2.var), Z_REF_P(value)); } - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH|ISSET) @@ -8189,32 +8189,31 @@ ZEND_VM_HANDLER(195, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED) { USE_OPLINE zend_array *ht; - uint32_t arg_count, first_extra_arg, i, n; - zval *p, *q; + uint32_t arg_count, result_size, skip; arg_count = EX_NUM_ARGS(); - ht = (zend_array *) emalloc(sizeof(zend_array)); if (OP1_TYPE == IS_CONST) { - i = Z_LVAL_P(EX_CONSTANT(opline->op1)); - if (arg_count < i) { - i = 0; + skip = Z_LVAL_P(EX_CONSTANT(opline->op1)); + if (arg_count < skip) { + result_size = 0; } else { - i = arg_count - i; + result_size = arg_count - skip; } - zend_hash_init(ht, i, NULL, ZVAL_PTR_DTOR, 0); } else { - zend_hash_init(ht, arg_count, NULL, ZVAL_PTR_DTOR, 0); + skip = 0; + result_size = arg_count; } + + ht = (zend_array *) emalloc(sizeof(zend_array)); + zend_hash_init(ht, result_size, NULL, ZVAL_PTR_DTOR, 0); ZVAL_ARR(EX_VAR(opline->result.var), ht); - if (arg_count) { - first_extra_arg = EX(func)->op_array.num_args; + + if (result_size) { + uint32_t first_extra_arg = EX(func)->op_array.num_args; zend_hash_real_init(ht, 1); ZEND_HASH_FILL_PACKED(ht) { - i = 0; - n = 0; - if (OP1_TYPE == IS_CONST) { - i = Z_LVAL_P(EX_CONSTANT(opline->op1)); - } + zval *p, *q; + uint32_t i = skip; p = EX_VAR_NUM(i); if (arg_count > first_extra_arg) { while (i < first_extra_arg) { @@ -8224,13 +8223,19 @@ ZEND_VM_HANDLER(195, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } - p = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T); + if (skip < first_extra_arg) { + skip = 0; + } else { + skip -= first_extra_arg; + } + p = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T + skip); } while (i < arg_count) { q = p; @@ -8239,14 +8244,15 @@ ZEND_VM_HANDLER(195, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED) if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } } ZEND_HASH_FILL_END(); - ht->nNumOfElements = n; + ht->nNumOfElements = result_size; } ZEND_VM_NEXT_OPCODE(); } @@ -8797,7 +8803,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_FE_FETCH_R, op->op2_type == IS_CV && (op1_inf variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(opline->op2.var EXECUTE_DATA_CC); zend_assign_to_variable(variable_ptr, value, IS_CV); - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } ZEND_VM_DEFINE_OP(137, ZEND_OP_DATA); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index e87f5c7251..89b9b2621f 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1325,7 +1325,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O { USE_OPLINE zend_free_op free_op1; - zval *args, *op2; + zval *args; SAVE_OPLINE(); args = get_zval_ptr(opline->op1_type, opline->op1, &free_op1, BP_VAR_R); @@ -8151,32 +8151,31 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_CONST_UNUSE { USE_OPLINE zend_array *ht; - uint32_t arg_count, first_extra_arg, i, n; - zval *p, *q; + uint32_t arg_count, result_size, skip; arg_count = EX_NUM_ARGS(); - ht = (zend_array *) emalloc(sizeof(zend_array)); if (IS_CONST == IS_CONST) { - i = Z_LVAL_P(EX_CONSTANT(opline->op1)); - if (arg_count < i) { - i = 0; + skip = Z_LVAL_P(EX_CONSTANT(opline->op1)); + if (arg_count < skip) { + result_size = 0; } else { - i = arg_count - i; + result_size = arg_count - skip; } - zend_hash_init(ht, i, NULL, ZVAL_PTR_DTOR, 0); } else { - zend_hash_init(ht, arg_count, NULL, ZVAL_PTR_DTOR, 0); + skip = 0; + result_size = arg_count; } + + ht = (zend_array *) emalloc(sizeof(zend_array)); + zend_hash_init(ht, result_size, NULL, ZVAL_PTR_DTOR, 0); ZVAL_ARR(EX_VAR(opline->result.var), ht); - if (arg_count) { - first_extra_arg = EX(func)->op_array.num_args; + + if (result_size) { + uint32_t first_extra_arg = EX(func)->op_array.num_args; zend_hash_real_init(ht, 1); ZEND_HASH_FILL_PACKED(ht) { - i = 0; - n = 0; - if (IS_CONST == IS_CONST) { - i = Z_LVAL_P(EX_CONSTANT(opline->op1)); - } + zval *p, *q; + uint32_t i = skip; p = EX_VAR_NUM(i); if (arg_count > first_extra_arg) { while (i < first_extra_arg) { @@ -8186,13 +8185,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_CONST_UNUSE if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } - p = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T); + if (skip < first_extra_arg) { + skip = 0; + } else { + skip -= first_extra_arg; + } + p = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T + skip); } while (i < arg_count) { q = p; @@ -8201,14 +8206,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_CONST_UNUSE if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } } ZEND_HASH_FILL_END(); - ht->nNumOfElements = n; + ht->nNumOfElements = result_size; } ZEND_VM_NEXT_OPCODE(); } @@ -16866,7 +16872,7 @@ fe_fetch_r_exit: GC_REFCOUNT(gc)++; } } - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_RW_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -17040,7 +17046,7 @@ fe_fetch_w_exit: Z_ADDREF_P(value); ZVAL_REF(EX_VAR(opline->op2.var), Z_REF_P(value)); } - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -24255,7 +24261,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_R_SIMPLE_ variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(opline->op2.var EXECUTE_DATA_CC); zend_assign_to_variable(variable_ptr, value, IS_CV); - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -24307,7 +24313,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_R_SIMPLE_ variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(opline->op2.var EXECUTE_DATA_CC); zend_assign_to_variable(variable_ptr, value, IS_CV); - ZEND_VM_NEXT_OPCODE(); + ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -29233,32 +29239,31 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_UNUSED_UNUS { USE_OPLINE zend_array *ht; - uint32_t arg_count, first_extra_arg, i, n; - zval *p, *q; + uint32_t arg_count, result_size, skip; arg_count = EX_NUM_ARGS(); - ht = (zend_array *) emalloc(sizeof(zend_array)); if (IS_UNUSED == IS_CONST) { - i = Z_LVAL_P(EX_CONSTANT(opline->op1)); - if (arg_count < i) { - i = 0; + skip = Z_LVAL_P(EX_CONSTANT(opline->op1)); + if (arg_count < skip) { + result_size = 0; } else { - i = arg_count - i; + result_size = arg_count - skip; } - zend_hash_init(ht, i, NULL, ZVAL_PTR_DTOR, 0); } else { - zend_hash_init(ht, arg_count, NULL, ZVAL_PTR_DTOR, 0); + skip = 0; + result_size = arg_count; } + + ht = (zend_array *) emalloc(sizeof(zend_array)); + zend_hash_init(ht, result_size, NULL, ZVAL_PTR_DTOR, 0); ZVAL_ARR(EX_VAR(opline->result.var), ht); - if (arg_count) { - first_extra_arg = EX(func)->op_array.num_args; + + if (result_size) { + uint32_t first_extra_arg = EX(func)->op_array.num_args; zend_hash_real_init(ht, 1); ZEND_HASH_FILL_PACKED(ht) { - i = 0; - n = 0; - if (IS_UNUSED == IS_CONST) { - i = Z_LVAL_P(EX_CONSTANT(opline->op1)); - } + zval *p, *q; + uint32_t i = skip; p = EX_VAR_NUM(i); if (arg_count > first_extra_arg) { while (i < first_extra_arg) { @@ -29268,13 +29273,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_UNUSED_UNUS if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } - p = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T); + if (skip < first_extra_arg) { + skip = 0; + } else { + skip -= first_extra_arg; + } + p = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T + skip); } while (i < arg_count) { q = p; @@ -29283,14 +29294,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_UNUSED_UNUS if (Z_OPT_REFCOUNTED_P(q)) { Z_ADDREF_P(q); } - n++; + } else { + q = &EG(uninitialized_zval); } ZEND_HASH_FILL_ADD(q); p++; i++; } } ZEND_HASH_FILL_END(); - ht->nNumOfElements = n; + ht->nNumOfElements = result_size; } ZEND_VM_NEXT_OPCODE(); } diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 3eebad0ef1..d28398315d 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -302,7 +302,7 @@ static union _zend_function *com_method_get(zend_object **object_ptr, zend_strin f.arg_info = ecalloc(bindptr.lpfuncdesc->cParams, sizeof(zend_arg_info)); for (i = 0; i < bindptr.lpfuncdesc->cParams; i++) { - f.arg_info[i].type = ZEND_TYPE_ENCODE(0,1);; + f.arg_info[i].type = ZEND_TYPE_ENCODE(0,1); if (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) { f.arg_info[i].pass_by_reference = ZEND_SEND_BY_REF; } diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 3684222f93..0d1152b987 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2508,7 +2508,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ zval_ptr_dtor(&ch->handlers->write_header->stream); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; - ZVAL_COPY(&ch->handlers->write_header->stream, zvalue);; + ZVAL_COPY(&ch->handlers->write_header->stream, zvalue); } else { php_error_docref(NULL, E_WARNING, "the provided file handle is not writable"); return FAILURE; diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 1e981ffcd2..ab92022340 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -3009,7 +3009,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP { int a; char *decode; - size_t len;; + size_t len; *pszEncoding = NULL; /* Copy the comment */ diff --git a/ext/imap/tests/imap_alerts_error.phpt b/ext/imap/tests/imap_alerts_error.phpt index ab13ec4632..ee13b13503 100644 --- a/ext/imap/tests/imap_alerts_error.phpt +++ b/ext/imap/tests/imap_alerts_error.phpt @@ -16,7 +16,7 @@ echo "*** Testing imap_alerts() : error conditions ***\n"; // One argument echo "\n-- Testing imap_alerts() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( imap_alerts($extra_arg) ); ?> diff --git a/ext/interbase/ibase_events.c b/ext/interbase/ibase_events.c index 36eca398fd..001c43dded 100644 --- a/ext/interbase/ibase_events.c +++ b/ext/interbase/ibase_events.c @@ -264,7 +264,6 @@ PHP_FUNCTION(ibase_set_event_handler) * link resource id (int) as arguments. The value returned from the function is * used to determine if the event handler should remain set. */ - zend_string *cb_name; zval *args, *cb_arg; ibase_db_link *ib_link; ibase_event *event; @@ -318,12 +317,12 @@ PHP_FUNCTION(ibase_set_event_handler) } /* get the callback */ - if (!zend_is_callable(cb_arg, 0, &cb_name)) { + if (!zend_is_callable(cb_arg, 0, NULL)) { + zend_string *cb_name = zend_get_callable_name(cb_arg); _php_ibase_module_error("Callback argument %s is not a callable function", ZSTR_VAL(cb_name)); zend_string_release(cb_name); RETURN_FALSE; } - zend_string_release(cb_name); /* allocate the event resource */ event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0); diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp index 00a5cc593c..f08e0ed3f3 100644 --- a/ext/intl/dateformat/dateformat_create.cpp +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -216,7 +216,9 @@ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct ) return_value = getThis(); if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) { if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); + zend_string *err = intl_error_get_message(NULL); + zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL)); + zend_string_release(err); } } zend_restore_error_handling(&error_handling); diff --git a/ext/intl/tests/dateformat_invalid_timezone.phpt b/ext/intl/tests/dateformat_invalid_timezone.phpt new file mode 100644 index 0000000000..5b54fa89bb --- /dev/null +++ b/ext/intl/tests/dateformat_invalid_timezone.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlDateFormat constructor failure +--INI-- +date.timezone=Mars/Utopia_Planitia +--SKIPIF-- +<?php +extension_loaded('intl') || print 'skip'; +--FILE-- +<?php + +try { + new \IntlDateFormatter('en_US', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL); + echo "Wat?"; +} catch (\IntlException $e) { + echo $e->getMessage(); +} +--EXPECT-- +IntlDateFormatter::__construct(): Invalid date.timezone value 'Mars/Utopia_Planitia', we selected the timezone 'UTC' for now. diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt index dce0714d4d..7d77057123 100644 --- a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt +++ b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt @@ -22,7 +22,7 @@ $rules = <<<RULES !!safe_reverse; RULES; $rbbi = new IntlRuleBasedBreakIterator($rules); -$rbbi->setText('sdfkjsdf88á.... ,;');; +$rbbi->setText('sdfkjsdf88á.... ,;'); $br = $rbbi->getBinaryRules(); diff --git a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt index a56f6bc488..4a654508cc 100644 --- a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt +++ b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt @@ -25,7 +25,7 @@ $rules = <<<RULES !!safe_reverse; RULES; $rbbi = new IntlRuleBasedBreakIterator($rules); -$rbbi->setText('sdfkjsdf88á.... ,;');; +$rbbi->setText('sdfkjsdf88á.... ,;'); do { var_dump($rbbi->current(), $rbbi->getRuleStatusVec()); @@ -56,4 +56,4 @@ array(1) { [0]=> int(4) } -==DONE==
\ No newline at end of file +==DONE== diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index d17719a285..717b8e7a46 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -2783,7 +2783,6 @@ PHP_FUNCTION(ldap_set_rebind_proc) { zval *link, *callback; ldap_linkdata *ld; - zend_string *callback_name; if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &link, &callback) != SUCCESS) { RETURN_FALSE; @@ -2804,12 +2803,12 @@ PHP_FUNCTION(ldap_set_rebind_proc) } /* callable? */ - if (!zend_is_callable(callback, 0, &callback_name)) { + if (!zend_is_callable(callback, 0, NULL)) { + zend_string *callback_name = zend_get_callable_name(callback); php_error_docref(NULL, E_WARNING, "Two arguments expected for '%s' to be a valid callback", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } - zend_string_release(callback_name); /* register rebind procedure */ if (Z_ISUNDEF(ld->rebindproc)) { diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c index 8663057fd2..e31bc19817 100644 --- a/ext/mysqli/mysqli_exception.c +++ b/ext/mysqli/mysqli_exception.c @@ -44,7 +44,7 @@ void php_mysqli_throw_sql_exception(char *sqlstate, int errorno, char *format, . va_start(arg, format); vspprintf(&message, 0, format, arg); - va_end(arg);; + va_end(arg); if (!(MyG(report_mode) & MYSQLI_REPORT_STRICT)) { php_error_docref(NULL, E_WARNING, "(%s/%d): %s", sqlstate, errorno, message); diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt index 59754bc278..75c4b02a29 100644 --- a/ext/mysqli/tests/065.phpt +++ b/ext/mysqli/tests/065.phpt @@ -41,7 +41,7 @@ if (!function_exists('mysqli_set_charset')) { printf("[005] Expecting 2/int got %s/%s\n", gettype($tmp), $tmp); if ('gbk' !== ($tmp = $mysql->character_set_name())) - printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp);; + printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp); } } $mysql->close(); diff --git a/ext/mysqli/tests/mysqli_debug.phpt b/ext/mysqli/tests/mysqli_debug.phpt index 2b754eac36..aa455d7f6e 100644 --- a/ext/mysqli/tests/mysqli_debug.phpt +++ b/ext/mysqli/tests/mysqli_debug.phpt @@ -17,7 +17,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) ?> --FILE-- <?php - require_once('connect.inc');; + require_once('connect.inc'); if (NULL !== ($tmp = @mysqli_debug())) printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); diff --git a/ext/mysqli/tests/mysqli_debug_append.phpt b/ext/mysqli/tests/mysqli_debug_append.phpt index fbb0d0a84e..68e600772b 100644 --- a/ext/mysqli/tests/mysqli_debug_append.phpt +++ b/ext/mysqli/tests/mysqli_debug_append.phpt @@ -20,7 +20,7 @@ if (!$IS_MYSQLND) ?> --FILE-- <?php - require_once('connect.inc');; + require_once('connect.inc'); if (true !== ($tmp = mysqli_debug(sprintf('d:t:O,%s/mysqli_debug_phpt.trace', sys_get_temp_dir())))) printf("[001] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt index 1de2eebb2e..b5ba9a5a05 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt @@ -20,7 +20,7 @@ if (!$IS_MYSQLND) ?> --FILE-- <?php - require_once('connect.inc');; + require_once('connect.inc'); require_once('table.inc'); function try_control_string($link, $control_string, $trace_file, $offset) { diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt index 257926bae9..2886694440 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt @@ -21,7 +21,7 @@ if (!$IS_MYSQLND) ?> --FILE-- <?php - require_once('connect.inc');; + require_once('connect.inc'); require_once('table.inc'); function try_control_string($link, $control_string, $trace_file, $offset) { @@ -125,4 +125,4 @@ if (!$IS_MYSQLND) require_once("clean_table.inc"); ?> --EXPECTF-- -done!
\ No newline at end of file +done! diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index 59bdb9cc85..7190567518 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -49,20 +49,18 @@ PHP_FUNCTION(oci_register_taf_callback) zval *z_connection; php_oci_connection *connection; zval *callback; - zend_string *callback_name; if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|z!", &z_connection, &callback) == FAILURE) { return; } if (callback) { - if (!zend_is_callable(callback, 0, &callback_name)) { + if (!zend_is_callable(callback, 0, NULL)) { + zend_string *callback_name = zend_get_callable_name(callback); php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } - - zend_string_release(callback_name); } PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); diff --git a/ext/oci8/tests/coll_019.phpt b/ext/oci8/tests/coll_019.phpt index 371c802ede..e0c896dce1 100644 --- a/ext/oci8/tests/coll_019.phpt +++ b/ext/oci8/tests/coll_019.phpt @@ -13,7 +13,7 @@ require(dirname(__FILE__).'/skipif.inc'); require dirname(__FILE__)."/connect.inc"; -$ora_sql = "DROP TYPE ".$type_name;; +$ora_sql = "DROP TYPE ".$type_name; $statement = oci_parse($c,$ora_sql); @oci_execute($statement); diff --git a/ext/oci8/tests/lob_040.phpt b/ext/oci8/tests/lob_040.phpt index 0a29dc1b9e..0d60054b22 100644 --- a/ext/oci8/tests/lob_040.phpt +++ b/ext/oci8/tests/lob_040.phpt @@ -29,9 +29,9 @@ for ($i = 0; $i < NUMLOBS; $i++) { } for ($i = 0; $i < NUMLOBS; $i++) { - echo "Row $i Size: " . $row[$i][0]->size() . "\n";; + echo "Row $i Size: " . $row[$i][0]->size() . "\n"; echo "Pos 1: " . $row[$i][0]->tell() . "\n"; - echo "Data: " . $row[$i][0]->read(5) . "\n";; + echo "Data: " . $row[$i][0]->read(5) . "\n"; echo "Pos 2: " . $row[$i][0]->tell() . "\n"; echo "Data: " . $row[$i][0]->read(12) . "\n"; } diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 7e375e8289..32db2ca9e9 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -596,7 +596,7 @@ static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_int ZEND_HASH_FOREACH_BUCKET(CG(auto_globals), p) { zend_auto_global *auto_global; - auto_global = (zend_auto_global*)Z_PTR(p->val);; + auto_global = (zend_auto_global*)Z_PTR(p->val); zend_string_addref(auto_global->name); auto_global->name = new_interned_string(auto_global->name); diff --git a/ext/opcache/zend_accelerator_debug.h b/ext/opcache/zend_accelerator_debug.h index 6445254232..01598deefd 100644 --- a/ext/opcache/zend_accelerator_debug.h +++ b/ext/opcache/zend_accelerator_debug.h @@ -28,6 +28,6 @@ #define ACCEL_LOG_INFO 3 #define ACCEL_LOG_DEBUG 4 -void zend_accel_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);; +void zend_accel_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); #endif /* _ZEND_ACCELERATOR_DEBUG_H */ diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index 738c6285d2..4f00574965 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -228,14 +228,14 @@ int zend_shared_alloc_startup(size_t requested_size) p_tmp_shared_globals = (zend_smm_shared_globals *) zend_shared_alloc(sizeof(zend_smm_shared_globals)); if (!p_tmp_shared_globals) { zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); - return ALLOC_FAILURE;; + return ALLOC_FAILURE; } memset(p_tmp_shared_globals, 0, sizeof(zend_smm_shared_globals)); tmp_shared_segments = zend_shared_alloc(shared_segments_array_size + ZSMMG(shared_segments_count) * sizeof(void *)); if (!tmp_shared_segments) { zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); - return ALLOC_FAILURE;; + return ALLOC_FAILURE; } copy_shared_segments(tmp_shared_segments, ZSMMG(shared_segments)[0], ZSMMG(shared_segments_count), S_H(segment_type_size)()); @@ -249,7 +249,7 @@ int zend_shared_alloc_startup(size_t requested_size) ZSMMG(shared_memory_state).positions = (int *)zend_shared_alloc(sizeof(int) * ZSMMG(shared_segments_count)); if (!ZSMMG(shared_memory_state).positions) { zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); - return ALLOC_FAILURE;; + return ALLOC_FAILURE; } ZCG(locked) = 0; diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index b78e41cb28..81456207bd 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1517,6 +1517,7 @@ PHP_MINIT_FUNCTION(openssl) REGISTER_LONG_CONSTANT("OPENSSL_RAW_DATA", OPENSSL_RAW_DATA, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_ZERO_PADDING", OPENSSL_ZERO_PADDING, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("OPENSSL_DONT_ZERO_PAD_KEY", OPENSSL_DONT_ZERO_PAD_KEY, CONST_CS|CONST_PERSISTENT); #ifndef OPENSSL_NO_TLSEXT /* SNI support included */ @@ -6410,20 +6411,7 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type, int key_len, password_len; size_t max_iv_len; - /* check and set key */ - password_len = (int) *ppassword_len; - key_len = EVP_CIPHER_key_length(cipher_type); - if (key_len > password_len) { - key = emalloc(key_len); - memset(key, 0, key_len); - memcpy(key, *ppassword, password_len); - *ppassword = (char *) key; - *ppassword_len = key_len; - *free_password = 1; - } else { - key = (unsigned char*)*ppassword; - *free_password = 0; - } + *free_password = 0; max_iv_len = EVP_CIPHER_iv_length(cipher_type); if (enc && *piv_len == 0 && max_iv_len > 0 && !mode->is_aead) { @@ -6448,9 +6436,28 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type, return FAILURE; } } - if (password_len > key_len && !EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len)) { - php_openssl_store_errors(); + /* check and set key */ + password_len = (int) *ppassword_len; + key_len = EVP_CIPHER_key_length(cipher_type); + if (key_len > password_len) { + if ((OPENSSL_DONT_ZERO_PAD_KEY & options) && !EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len)) { + php_openssl_store_errors(); + php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher method"); + return FAILURE; + } + key = emalloc(key_len); + memset(key, 0, key_len); + memcpy(key, *ppassword, password_len); + *ppassword = (char *) key; + *ppassword_len = key_len; + *free_password = 1; + } else { + if (password_len > key_len && !EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len)) { + php_openssl_store_errors(); + } + key = (unsigned char*)*ppassword; } + if (!EVP_CipherInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)*piv, enc)) { php_openssl_store_errors(); return FAILURE; diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h index 14a194c7e6..a157969883 100644 --- a/ext/openssl/php_openssl.h +++ b/ext/openssl/php_openssl.h @@ -31,6 +31,7 @@ extern zend_module_entry openssl_module_entry; #define OPENSSL_RAW_DATA 1 #define OPENSSL_ZERO_PADDING 2 +#define OPENSSL_DONT_ZERO_PAD_KEY 4 #define OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH 0x0B080074 diff --git a/ext/openssl/tests/bug71917.phpt b/ext/openssl/tests/bug71917.phpt new file mode 100644 index 0000000000..d4415b3e32 --- /dev/null +++ b/ext/openssl/tests/bug71917.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #71917: openssl_open() returns junk on envelope < 16 bytes +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip openssl not loaded"); +?> +--FILE-- +<?php +function test($envkey) { + $publicKey = "file://" . dirname(__FILE__) . "/public.key"; + $privateKey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; + openssl_public_encrypt($envkey, $envelope, $publicKey); + $sealed = openssl_encrypt('plaintext', 'rc4', $envkey, OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY); + openssl_open($sealed, $output, $envelope, $privateKey, 'rc4'); + var_dump($output === 'plaintext'); +} + +// works - key of 16 bytes +test('1234567890123456i'); +// fails - key of 15 bytes +test('123456789012345'); +?> +--EXPECT-- +bool(true) +bool(true) diff --git a/ext/openssl/tests/bug72362.phpt b/ext/openssl/tests/bug72362.phpt new file mode 100644 index 0000000000..40acdbed0c --- /dev/null +++ b/ext/openssl/tests/bug72362.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #72362: OpenSSL Blowfish encryption is incorrect for short keys +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip openssl not loaded"); +?> +--FILE-- +<?php +var_dump(bin2hex(openssl_encrypt("this is a test string","bf-ecb","12345678", OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY))); +var_dump(bin2hex(openssl_encrypt("this is a test string","bf-ecb","1234567812345678" , OPENSSL_RAW_DATA))); +?> +--EXPECT-- +string(48) "e3214d1b16e574828c8a3e222202dde81afd1ad2cb165ab3" +string(48) "e3214d1b16e574828c8a3e222202dde81afd1ad2cb165ab3" diff --git a/ext/openssl/tests/openssl_decrypt_basic.phpt b/ext/openssl/tests/openssl_decrypt_basic.phpt index 1c29767cc5..37d17150fb 100644 --- a/ext/openssl/tests/openssl_decrypt_basic.phpt +++ b/ext/openssl/tests/openssl_decrypt_basic.phpt @@ -24,8 +24,13 @@ $padded_data = $data . str_repeat(' ', 16 - (strlen($data) % 16)); $encrypted = openssl_encrypt($padded_data, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); $output = openssl_decrypt($encrypted, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv); var_dump(rtrim($output)); +// if we want to prefer variable length cipher setting +$encrypted = openssl_encrypt($data, "bf-ecb", $password, OPENSSL_DONT_ZERO_PAD_KEY); +$output = openssl_decrypt($encrypted, "bf-ecb", $password, OPENSSL_DONT_ZERO_PAD_KEY); +var_dump($output); ?> --EXPECT-- string(45) "openssl_encrypt() and openssl_decrypt() tests" string(45) "openssl_encrypt() and openssl_decrypt() tests" string(45) "openssl_encrypt() and openssl_decrypt() tests" +string(45) "openssl_encrypt() and openssl_decrypt() tests" diff --git a/ext/openssl/tests/openssl_encrypt_error.phpt b/ext/openssl/tests/openssl_encrypt_error.phpt index 791c431211..ea69ad9ee2 100644 --- a/ext/openssl/tests/openssl_encrypt_error.phpt +++ b/ext/openssl/tests/openssl_encrypt_error.phpt @@ -23,6 +23,9 @@ var_dump(openssl_encrypt($data, $method, $arr)); // invalid using of an authentication tag var_dump(openssl_encrypt($data, $method, $password, 0, $iv, $wrong)); + +// padding of the key is disabled +var_dump(openssl_encrypt($data, $method, $password, OPENSSL_DONT_ZERO_PAD_KEY, $iv)); ?> --EXPECTF-- Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d @@ -48,3 +51,6 @@ NULL Warning: openssl_encrypt(): The authenticated tag cannot be provided for cipher that doesn not support AEAD in %s on line %d string(44) "iPR4HulskuaP5Z6me5uImk6BqVyJG73+63tkPauVZYk=" + +Warning: openssl_encrypt(): Key length cannot be set for the cipher method in %s on line %d +bool(false) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index fd8c506738..d82fed294a 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -990,7 +990,6 @@ PHP_FUNCTION(pcntl_exec) PHP_FUNCTION(pcntl_signal) { zval *handle; - zend_string *func_name; zend_long signo; zend_bool restart_syscalls = 1; @@ -1031,13 +1030,13 @@ PHP_FUNCTION(pcntl_signal) RETURN_TRUE; } - if (!zend_is_callable(handle, 0, &func_name)) { + if (!zend_is_callable(handle, 0, NULL)) { + zend_string *func_name = zend_get_callable_name(handle); PCNTL_G(last_error) = EINVAL; php_error_docref(NULL, E_WARNING, "%s is not a callable function name error", ZSTR_VAL(func_name)); zend_string_release(func_name); RETURN_FALSE; } - zend_string_release(func_name); /* Add the function name to our signal table */ if (zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle)) { diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 615c83ae65..131f096f47 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -2037,7 +2037,6 @@ static PHP_FUNCTION(preg_replace_callback) { zval *regex, *replace, *subject, *zcount = NULL; zend_long limit = -1; - zend_string *callback_name; int replace_count; zend_fcall_info fci; zend_fcall_info_cache fcc; @@ -2052,13 +2051,13 @@ static PHP_FUNCTION(preg_replace_callback) Z_PARAM_ZVAL_DEREF(zcount) ZEND_PARSE_PARAMETERS_END(); - if (!zend_is_callable_ex(replace, NULL, 0, &callback_name, &fcc, NULL)) { + if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) { + zend_string *callback_name = zend_get_callable_name(replace); php_error_docref(NULL, E_WARNING, "Requires argument 2, '%s', to be a valid callback", ZSTR_VAL(callback_name)); zend_string_release(callback_name); ZVAL_STR(return_value, zval_get_string(subject)); return; } - zend_string_release(callback_name); fci.size = sizeof(fci); fci.object = NULL; @@ -2079,7 +2078,6 @@ static PHP_FUNCTION(preg_replace_callback_array) zval regex, zv, *replace, *subject, *pattern, *zcount = NULL; zend_long limit = -1; zend_string *str_idx; - zend_string *callback_name; int replace_count = 0; zend_fcall_info fci; zend_fcall_info_cache fcc; @@ -2105,7 +2103,8 @@ static PHP_FUNCTION(preg_replace_callback_array) RETURN_NULL(); } - if (!zend_is_callable_ex(replace, NULL, 0, &callback_name, &fcc, NULL)) { + if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) { + zend_string *callback_name = zend_get_callable_name(replace); php_error_docref(NULL, E_WARNING, "'%s' is not a valid callback", ZSTR_VAL(callback_name)); zend_string_release(callback_name); zval_ptr_dtor(®ex); @@ -2113,7 +2112,6 @@ static PHP_FUNCTION(preg_replace_callback_array) ZVAL_COPY(return_value, subject); return; } - zend_string_release(callback_name); ZVAL_COPY_VALUE(&fci.function_name, replace); diff --git a/ext/pcre/tests/split2.phpt b/ext/pcre/tests/split2.phpt index ccbb7242fd..b0411e6df2 100644 --- a/ext/pcre/tests/split2.phpt +++ b/ext/pcre/tests/split2.phpt @@ -8,7 +8,7 @@ pcre.jit=0 var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE)); var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_OFFSET_CAPTURE)); var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)); -var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE));; +var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE)); var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE)); var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE)); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index c238ea0fb0..a826240c76 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -858,7 +858,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_ case PDO_FETCH_NAMED: if (!return_all) { ZVAL_NEW_ARR(return_value); - zend_hash_init(Z_ARRVAL_P(return_value), stmt->column_count, NULL, ZVAL_PTR_DTOR, 0);; + zend_hash_init(Z_ARRVAL_P(return_value), stmt->column_count, NULL, ZVAL_PTR_DTOR, 0); } else { array_init(return_value); } diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index fed9dbed2f..3d32f232e8 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -515,7 +515,6 @@ static PHP_METHOD(SQLite, sqliteCreateFunction) size_t func_name_len; zend_long argc = -1; zend_long flags = 0; - zend_string *cbname = NULL; pdo_dbh_t *dbh; pdo_sqlite_db_handle *H; int ret; @@ -531,12 +530,12 @@ static PHP_METHOD(SQLite, sqliteCreateFunction) dbh = Z_PDO_DBH_P(getThis()); PDO_CONSTRUCT_CHECK; - if (!zend_is_callable(callback, 0, &cbname)) { + if (!zend_is_callable(callback, 0, NULL)) { + zend_string *cbname = zend_get_callable_name(callback); php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } - zend_string_release(cbname); H = (pdo_sqlite_db_handle *)dbh->driver_data; @@ -588,7 +587,6 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate) char *func_name; size_t func_name_len; zend_long argc = -1; - zend_string *cbname = NULL; pdo_dbh_t *dbh; pdo_sqlite_db_handle *H; int ret; @@ -604,18 +602,19 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate) dbh = Z_PDO_DBH_P(getThis()); PDO_CONSTRUCT_CHECK; - if (!zend_is_callable(step_callback, 0, &cbname)) { + if (!zend_is_callable(step_callback, 0, NULL)) { + zend_string *cbname = zend_get_callable_name(step_callback); php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } - zend_string_release(cbname); - if (!zend_is_callable(fini_callback, 0, &cbname)) { + + if (!zend_is_callable(fini_callback, 0, NULL)) { + zend_string *cbname = zend_get_callable_name(fini_callback); php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } - zend_string_release(cbname); H = (pdo_sqlite_db_handle *)dbh->driver_data; @@ -651,7 +650,6 @@ static PHP_METHOD(SQLite, sqliteCreateCollation) zval *callback; char *collation_name; size_t collation_name_len; - zend_string *cbname = NULL; pdo_dbh_t *dbh; pdo_sqlite_db_handle *H; int ret; @@ -664,12 +662,12 @@ static PHP_METHOD(SQLite, sqliteCreateCollation) dbh = Z_PDO_DBH_P(getThis()); PDO_CONSTRUCT_CHECK; - if (!zend_is_callable(callback, 0, &cbname)) { + if (!zend_is_callable(callback, 0, NULL)) { + zend_string *cbname = zend_get_callable_name(callback); php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } - zend_string_release(cbname); H = (pdo_sqlite_db_handle *)dbh->driver_data; diff --git a/ext/phar/tests/011.phpt b/ext/phar/tests/011.phpt index 4a1f0dd42c..83bae148e0 100644 --- a/ext/phar/tests/011.phpt +++ b/ext/phar/tests/011.phpt @@ -15,7 +15,7 @@ __HALT_COMPILER(); ?>"; // compressed file length does not match incompressed lentgh for an uncompressed file $files = array(); -$files['a'] = array('cont'=>'a','ulen'=>1,'clen'=>2);; +$files['a'] = array('cont'=>'a','ulen'=>1,'clen'=>2); include 'files/phar_test.inc'; try { include $fname; diff --git a/ext/phar/tests/pharfileinfo_getcrc32.phpt b/ext/phar/tests/pharfileinfo_getcrc32.phpt index dfa12f4ca4..436ac7c590 100644 --- a/ext/phar/tests/pharfileinfo_getcrc32.phpt +++ b/ext/phar/tests/pharfileinfo_getcrc32.phpt @@ -16,7 +16,7 @@ __HALT_COMPILER(); ?>"; // compressed file length does not match incompressed lentgh for an uncompressed file $files = array(); -$files['a/subdir/here'] = array('cont'=>'a','ulen'=>1,'clen'=>1);; +$files['a/subdir/here'] = array('cont'=>'a','ulen'=>1,'clen'=>1); include 'files/phar_test.inc'; $b = new PharFileInfo($pname . '/a/subdir'); @@ -46,4 +46,4 @@ echo $e->getMessage() . "\n"; Phar entry is a directory, does not have a CRC Phar entry was not CRC checked int(%s) -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/posix/tests/posix_getuid_error.phpt b/ext/posix/tests/posix_getuid_error.phpt index e759e68bf5..42a35512a0 100644 --- a/ext/posix/tests/posix_getuid_error.phpt +++ b/ext/posix/tests/posix_getuid_error.phpt @@ -16,7 +16,7 @@ echo "*** Testing posix_getuid() : error conditions ***\n"; // One argument echo "\n-- Testing posix_getuid() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( posix_getuid($extra_arg) ); echo "Done"; diff --git a/ext/posix/tests/posix_times_error.phpt b/ext/posix/tests/posix_times_error.phpt index 2766bc9483..b705047358 100644 --- a/ext/posix/tests/posix_times_error.phpt +++ b/ext/posix/tests/posix_times_error.phpt @@ -16,7 +16,7 @@ echo "*** Testing posix_times() : error conditions ***\n"; // One argument echo "\n-- Testing posix_times() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( posix_times($extra_arg) ); echo "Done"; diff --git a/ext/posix/tests/posix_uname_error.phpt b/ext/posix/tests/posix_uname_error.phpt index 4c753feae4..b44f4ae8ca 100644 --- a/ext/posix/tests/posix_uname_error.phpt +++ b/ext/posix/tests/posix_uname_error.phpt @@ -16,7 +16,7 @@ echo "*** Testing posix_uname() : error conditions ***\n"; // One argument echo "\n-- Testing posix_uname() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( posix_uname($extra_arg) ); echo "Done"; diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 53a4c9e9ab..b30ace1a7c 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -326,7 +326,7 @@ PHP_FUNCTION(readline_info) if (value) { /* XXX if (rl_readline_name) free(rl_readline_name); */ convert_to_string_ex(value); - rl_readline_name = strdup(Z_STRVAL_P(value));; + rl_readline_name = strdup(Z_STRVAL_P(value)); } RETVAL_STRING(SAFE_STRING(oldstr)); } else if (!strcasecmp(what, "attempted_completion_over")) { @@ -507,7 +507,7 @@ static char **_readline_completion_cb(const char *text, int start, int end) return NULL; } matches[0] = strdup(""); - matches[1] = '\0'; + matches[1] = NULL; } } } @@ -522,19 +522,18 @@ static char **_readline_completion_cb(const char *text, int start, int end) PHP_FUNCTION(readline_completion_function) { - zval *arg = NULL; - zend_string *name = NULL; + zval *arg; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg)) { RETURN_FALSE; } - if (!zend_is_callable(arg, 0, &name)) { + if (!zend_is_callable(arg, 0, NULL)) { + zend_string *name = zend_get_callable_name(arg); php_error_docref(NULL, E_WARNING, "%s is not callable", ZSTR_VAL(name)); zend_string_release(name); RETURN_FALSE; } - zend_string_release(name); zval_ptr_dtor(&_readline_completion); ZVAL_COPY(&_readline_completion, arg); @@ -570,7 +569,6 @@ static void php_rl_callback_handler(char *the_line) PHP_FUNCTION(readline_callback_handler_install) { zval *callback; - zend_string *name = NULL; char *prompt; size_t prompt_len; @@ -578,12 +576,12 @@ PHP_FUNCTION(readline_callback_handler_install) return; } - if (!zend_is_callable(callback, 0, &name)) { + if (!zend_is_callable(callback, 0, NULL)) { + zend_string *name = zend_get_callable_name(callback); php_error_docref(NULL, E_WARNING, "%s is not callable", ZSTR_VAL(name)); zend_string_release(name); RETURN_FALSE; } - zend_string_release(name); if (Z_TYPE(_prepped_callback) != IS_UNDEF) { rl_callback_handler_remove(); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index badbf8eb88..c9243d6bcc 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4753,7 +4753,7 @@ ZEND_METHOD(reflection_class, newInstance) fcc.initialized = 1; fcc.function_handler = constructor; - fcc.calling_scope = zend_get_executed_scope();; + fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(return_value); fcc.object = Z_OBJ_P(return_value); diff --git a/ext/reflection/tests/bug38194.phpt b/ext/reflection/tests/bug38194.phpt index d12f4e4a77..1430ba45ae 100644 --- a/ext/reflection/tests/bug38194.phpt +++ b/ext/reflection/tests/bug38194.phpt @@ -2,9 +2,9 @@ Reflection Bug #38194 (ReflectionClass::isSubclassOf() returns TRUE for the class itself) --FILE-- <?php -class Object { } +class ObjectOne { } -$objectClass= new ReflectionClass('Object'); +$objectClass = new ReflectionClass('ObjectOne'); var_dump($objectClass->isSubclassOf($objectClass)); ?> --EXPECT-- diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt index 988f1c8953..b02c8210e5 100644 --- a/ext/reflection/tests/bug38217.phpt +++ b/ext/reflection/tests/bug38217.phpt @@ -3,21 +3,21 @@ Bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory --FILE-- <?php -class Object { +class ObjectOne { public function __construct() { } } -$class= new ReflectionClass('Object'); +$class= new ReflectionClass('ObjectOne'); var_dump($class->newInstanceArgs()); -class Object1 { +class ObjectTwo { public function __construct($var) { var_dump($var); } } -$class= new ReflectionClass('Object1'); +$class= new ReflectionClass('ObjectTwo'); try { var_dump($class->newInstanceArgs()); } catch (Throwable $e) { @@ -29,10 +29,10 @@ var_dump($class->newInstanceArgs(array('test'))); echo "Done\n"; ?> --EXPECTF-- -object(Object)#%d (0) { +object(ObjectOne)#%d (0) { } -Exception: Too few arguments to function Object1::__construct(), 0 passed and exactly 1 expected +Exception: Too few arguments to function ObjectTwo::__construct(), 0 passed and exactly 1 expected string(4) "test" -object(Object1)#%d (0) { +object(ObjectTwo)#%d (0) { } Done diff --git a/ext/session/session.c b/ext/session/session.c index c51d51b46f..7bc3a49abf 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1830,7 +1830,6 @@ static PHP_FUNCTION(session_set_save_handler) { zval *args = NULL; int i, num_args, argc = ZEND_NUM_ARGS(); - zend_string *name; zend_string *ini_name, *ini_val; if (PS(session_status) == php_session_active) { @@ -1960,12 +1959,12 @@ static PHP_FUNCTION(session_set_save_handler) /* At this point argc can only be between 6 and PS_NUM_APIS */ for (i = 0; i < argc; i++) { - if (!zend_is_callable(&args[i], 0, &name)) { + if (!zend_is_callable(&args[i], 0, NULL)) { + zend_string *name = zend_get_callable_name(&args[i]); php_error_docref(NULL, E_WARNING, "Argument %d is not a valid callback", i+1); zend_string_release(name); RETURN_FALSE; } - zend_string_release(name); } if (PS(mod) && PS(mod) != &ps_mod_user) { diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 5333b86eab..a88d14fb1a 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -283,16 +283,6 @@ static encodePtr find_encoder_by_type_name(sdlPtr sdl, const char *type) return NULL; } -static zval *soap_hash_str_find_deref(HashTable *ht, const char *str, size_t len) { - zval *zv = zend_hash_str_find(ht, str, len); - if (!zv) { - return NULL; - } - - ZVAL_DEREF(zv); - return zv; -} - static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node) { xmlNodePtr node_ptr; @@ -402,14 +392,14 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml encodePtr enc = NULL; HashTable *ht = Z_OBJPROP_P(data); - if ((ztype = soap_hash_str_find_deref(ht, "enc_type", sizeof("enc_type")-1)) == NULL || + if ((ztype = zend_hash_str_find_deref(ht, "enc_type", sizeof("enc_type")-1)) == NULL || Z_TYPE_P(ztype) != IS_LONG) { soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property"); } - if ((zstype = soap_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && + if ((zstype = zend_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && Z_TYPE_P(zstype) == IS_STRING) { - if ((zns = soap_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && + if ((zns = zend_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && Z_TYPE_P(zns) == IS_STRING) { enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_P(zns), Z_STRVAL_P(zstype)); } else { @@ -436,13 +426,13 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml enc = encode; } - zdata = soap_hash_str_find_deref(ht, "enc_value", sizeof("enc_value")-1); + zdata = zend_hash_str_find_deref(ht, "enc_value", sizeof("enc_value")-1); node = master_to_xml(enc, zdata, style, parent); if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) { - if ((zstype = soap_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && + if ((zstype = zend_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && Z_TYPE_P(zstype) == IS_STRING) { - if ((zns = soap_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && + if ((zns = zend_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && Z_TYPE_P(zns) == IS_STRING) { set_ns_and_type_ex(node, Z_STRVAL_P(zns), Z_STRVAL_P(zstype)); } else { @@ -451,11 +441,11 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml } } - if ((zname = soap_hash_str_find_deref(ht, "enc_name", sizeof("enc_name")-1)) != NULL && + if ((zname = zend_hash_str_find_deref(ht, "enc_name", sizeof("enc_name")-1)) != NULL && Z_TYPE_P(zname) == IS_STRING) { xmlNodeSetName(node, BAD_CAST(Z_STRVAL_P(zname))); } - if ((znamens = soap_hash_str_find_deref(ht, "enc_namens", sizeof("enc_namens")-1)) != NULL && + if ((znamens = zend_hash_str_find_deref(ht, "enc_namens", sizeof("enc_namens")-1)) != NULL && Z_TYPE_P(znamens) == IS_STRING) { xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_P(znamens)); xmlSetNs(node, nsp); @@ -1214,7 +1204,7 @@ static zval* get_zval_property(zval* object, char* name, zval *rv) ZVAL_DEREF(data); return data; } else if (Z_TYPE_P(object) == IS_ARRAY) { - return soap_hash_str_find_deref(Z_ARRVAL_P(object), name, strlen(name)); + return zend_hash_str_find_deref(Z_ARRVAL_P(object), name, strlen(name)); } return NULL; } @@ -1429,7 +1419,7 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z zval *classname; zend_class_entry *tmp; - if ((classname = soap_hash_str_find_deref(SOAP_GLOBAL(class_map), type->type_str, strlen(type->type_str))) != NULL && + if ((classname = zend_hash_str_find_deref(SOAP_GLOBAL(class_map), type->type_str, strlen(type->type_str))) != NULL && Z_TYPE_P(classname) == IS_STRING && (tmp = zend_fetch_class(Z_STR_P(classname), ZEND_FETCH_CLASS_AUTO)) != NULL) { ce = tmp; @@ -3535,20 +3525,20 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type) Z_OBJCE_P(tmp) == soap_var_class_entry) { zval *ztype; - if ((ztype = soap_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_type", sizeof("enc_type")-1)) == NULL || + if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_type", sizeof("enc_type")-1)) == NULL || Z_TYPE_P(ztype) != IS_LONG) { soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property"); } cur_type = Z_LVAL_P(ztype); - if ((ztype = soap_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_stype", sizeof("enc_stype")-1)) != NULL && + if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_stype", sizeof("enc_stype")-1)) != NULL && Z_TYPE_P(ztype) == IS_STRING) { cur_stype = Z_STRVAL_P(ztype); } else { cur_stype = NULL; } - if ((ztype = soap_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_ns", sizeof("enc_ns")-1)) != NULL && + if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_ns", sizeof("enc_ns")-1)) != NULL && Z_TYPE_P(ztype) == IS_STRING) { cur_ns = Z_STRVAL_P(ztype); } else { diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 68b61304b8..32cc648a28 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -167,7 +167,6 @@ ZEND_DECLARE_MODULE_GLOBALS(soap) static void (*old_error_handler)(int, const char *, const uint32_t, const char*, va_list); -#ifdef va_copy #define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \ { \ va_list copy; \ @@ -175,12 +174,6 @@ static void (*old_error_handler)(int, const char *, const uint32_t, const char*, old_error_handler(error_num, error_filename, error_lineno, format, copy); \ va_end(copy); \ } -#else -#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \ -{ \ - old_error_handler(error_num, error_filename, error_lineno, format, args); \ -} -#endif #define PHP_SOAP_SERVER_CLASSNAME "SoapServer" #define PHP_SOAP_CLIENT_CLASSNAME "SoapClient" @@ -2163,19 +2156,14 @@ static void soap_error_handler(int error_num, const char *error_filename, const char* code = SOAP_GLOBAL(error_code); char buffer[1024]; size_t buffer_len; -#ifdef va_copy va_list argcopy; -#endif zend_object **old_objects; int old = PG(display_errors); -#ifdef va_copy va_copy(argcopy, args); buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy); va_end(argcopy); -#else - buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args); -#endif + buffer[sizeof(buffer)-1]=0; if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) { buffer_len = sizeof(buffer) - 1; @@ -2216,9 +2204,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const int old = PG(display_errors); int fault = 0; zval fault_obj; -#ifdef va_copy va_list argcopy; -#endif if (error_num == E_USER_ERROR || error_num == E_COMPILE_ERROR || @@ -2246,13 +2232,10 @@ static void soap_error_handler(int error_num, const char *error_filename, const size_t buffer_len; zval outbuflen; -#ifdef va_copy va_copy(argcopy, args); buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy); va_end(argcopy); -#else - buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args); -#endif + buffer[sizeof(buffer)-1]=0; if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) { buffer_len = sizeof(buffer) - 1; diff --git a/ext/soap/tests/bugs/bug29844.phpt b/ext/soap/tests/bugs/bug29844.phpt index efaccbc31a..a3006639b1 100644 --- a/ext/soap/tests/bugs/bug29844.phpt +++ b/ext/soap/tests/bugs/bug29844.phpt @@ -18,7 +18,7 @@ class LocalSoapClient extends SoapClient { function __construct($wsdl, $options) { parent::__construct($wsdl, $options); $this->server = new SoapServer($wsdl, $options); - $this->server->setClass('hello_world');; + $this->server->setClass('hello_world'); } function __doRequest($request, $location, $action, $version, $one_way = 0) { diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index b56c2388d9..04c98d836d 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -907,7 +907,6 @@ PHP_METHOD(sqlite3, createFunction) char *sql_func; size_t sql_func_len; zval *callback_func; - zend_string *callback_name; zend_long sql_func_num_args = -1; zend_long flags = 0; db_obj = Z_SQLITE3_DB_P(object); @@ -922,12 +921,12 @@ PHP_METHOD(sqlite3, createFunction) RETURN_FALSE; } - if (!zend_is_callable(callback_func, 0, &callback_name)) { + if (!zend_is_callable(callback_func, 0, NULL)) { + zend_string *callback_name = zend_get_callable_name(callback_func); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } - zend_string_release(callback_name); func = (php_sqlite3_func *)ecalloc(1, sizeof(*func)); @@ -956,7 +955,6 @@ PHP_METHOD(sqlite3, createAggregate) zval *object = getThis(); php_sqlite3_func *func; char *sql_func; - zend_string *callback_name; size_t sql_func_len; zval *step_callback, *fini_callback; zend_long sql_func_num_args = -1; @@ -972,19 +970,19 @@ PHP_METHOD(sqlite3, createAggregate) RETURN_FALSE; } - if (!zend_is_callable(step_callback, 0, &callback_name)) { + if (!zend_is_callable(step_callback, 0, NULL)) { + zend_string *callback_name = zend_get_callable_name(step_callback); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } - zend_string_release(callback_name); - if (!zend_is_callable(fini_callback, 0, &callback_name)) { + if (!zend_is_callable(fini_callback, 0, NULL)) { + zend_string *callback_name = zend_get_callable_name(fini_callback); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } - zend_string_release(callback_name); func = (php_sqlite3_func *)ecalloc(1, sizeof(*func)); @@ -1014,7 +1012,6 @@ PHP_METHOD(sqlite3, createCollation) zval *object = getThis(); php_sqlite3_collation *collation; char *collation_name; - zend_string *callback_name; size_t collation_name_len; zval *callback_func; db_obj = Z_SQLITE3_DB_P(object); @@ -1029,12 +1026,12 @@ PHP_METHOD(sqlite3, createCollation) RETURN_FALSE; } - if (!zend_is_callable(callback_func, 0, &callback_name)) { + if (!zend_is_callable(callback_func, 0, NULL)) { + zend_string *callback_name = zend_get_callable_name(callback_func); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } - zend_string_release(callback_name); collation = (php_sqlite3_collation *)ecalloc(1, sizeof(*collation)); if (sqlite3_create_collation(db_obj->db, collation_name, SQLITE_UTF8, collation, php_sqlite3_callback_compare) == SQLITE_OK) { diff --git a/ext/standard/array.c b/ext/standard/array.c index 7055b2c86b..ab34ac4a28 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4549,7 +4549,7 @@ static int zval_user_compare(zval *a, zval *b) /* {{{ */ if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache)) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { zend_long ret = zval_get_long(&retval); zval_ptr_dtor(&retval); - return ret < 0 ? -1 : ret > 0 ? 1 : 0;; + return ret < 0 ? -1 : ret > 0 ? 1 : 0; } else { return 0; } diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 8f73153bba..383e988090 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4976,19 +4976,13 @@ static int user_shutdown_function_call(zval *zv) /* {{{ */ { php_shutdown_function_entry *shutdown_function_entry = Z_PTR_P(zv); zval retval; - zend_string *function_name; - if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, &function_name)) { - if (function_name) { - php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); - zend_string_release(function_name); - } else { - php_error(E_WARNING, "(Registered shutdown functions) Unable to call - function does not exist"); - } - return 0; - } - if (function_name) { + if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, NULL)) { + zend_string *function_name + = zend_get_callable_name(&shutdown_function_entry->arguments[0]); + php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); zend_string_release(function_name); + return 0; } if (call_user_function(EG(function_table), NULL, @@ -5102,7 +5096,6 @@ PHPAPI void php_free_shutdown_functions(void) /* {{{ */ PHP_FUNCTION(register_shutdown_function) { php_shutdown_function_entry shutdown_function_entry; - zend_string *callback_name = NULL; int i; shutdown_function_entry.arg_count = ZEND_NUM_ARGS(); @@ -5119,13 +5112,12 @@ PHP_FUNCTION(register_shutdown_function) } /* Prevent entering of anything but valid callback (syntax check only!) */ - if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0, &callback_name)) { - if (callback_name) { - php_error_docref(NULL, E_WARNING, "Invalid shutdown callback '%s' passed", ZSTR_VAL(callback_name)); - } else { - php_error_docref(NULL, E_WARNING, "Invalid shutdown callback passed"); - } + if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0, NULL)) { + zend_string *callback_name + = zend_get_callable_name(&shutdown_function_entry.arguments[0]); + php_error_docref(NULL, E_WARNING, "Invalid shutdown callback '%s' passed", ZSTR_VAL(callback_name)); efree(shutdown_function_entry.arguments); + zend_string_release(callback_name); RETVAL_FALSE; } else { if (!BG(user_shutdown_function_names)) { @@ -5138,9 +5130,6 @@ PHP_FUNCTION(register_shutdown_function) } zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry)); } - if (callback_name) { - zend_string_release(callback_name); - } } /* }}} */ diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index d6776aaf96..cff0f9c4c2 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -921,7 +921,7 @@ literal: if (numVars) { char __buf[2]; __buf[0] = sch; - __buf[1] = '\0';; + __buf[1] = '\0'; current = args[objIndex++]; zval_dtor(*current); ZVAL_STRINGL( *current, __buf, 1); diff --git a/ext/standard/tests/array/sizeof_error.phpt b/ext/standard/tests/array/sizeof_error.phpt index 79a75f3153..c6274830cf 100644 --- a/ext/standard/tests/array/sizeof_error.phpt +++ b/ext/standard/tests/array/sizeof_error.phpt @@ -17,7 +17,7 @@ echo "-- Testing sizeof() with zero arguments --\n"; var_dump( sizeof() ); echo "-- Testing sizeof() function with more than two arguments under COUNT_NORMAL mode --\n"; $var = 100; -$extra_arg = 10;; +$extra_arg = 10; var_dump( sizeof($var, COUNT_NORMAL, $extra_arg) ); echo "-- Testing sizeof() function with more than two arguments under COUNT_RECURSIVE mode --\n"; var_dump( sizeof($var, COUNT_RECURSIVE, $extra_arg) ); diff --git a/ext/standard/tests/class_object/get_declared_classes_error_001.phpt b/ext/standard/tests/class_object/get_declared_classes_error_001.phpt index d5b40beee8..ff01feb360 100644 --- a/ext/standard/tests/class_object/get_declared_classes_error_001.phpt +++ b/ext/standard/tests/class_object/get_declared_classes_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing get_declared_classes() : error conditions ***\n"; // One argument echo "\n-- Testing get_declared_classes() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( get_declared_classes($extra_arg) ); echo "Done"; diff --git a/ext/standard/tests/class_object/get_declared_interfaces_error_001.phpt b/ext/standard/tests/class_object/get_declared_interfaces_error_001.phpt index 2a7f308a34..63b02b85c3 100644 --- a/ext/standard/tests/class_object/get_declared_interfaces_error_001.phpt +++ b/ext/standard/tests/class_object/get_declared_interfaces_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing get_declared_interfaces() : error conditions ***\n"; // One argument echo "\n-- Testing get_declared_interfaces() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( get_declared_interfaces($extra_arg) ); echo "Done"; diff --git a/ext/standard/tests/class_object/get_declared_traits_error_001.phpt b/ext/standard/tests/class_object/get_declared_traits_error_001.phpt index f7a00da0dd..0d35fa6d13 100644 --- a/ext/standard/tests/class_object/get_declared_traits_error_001.phpt +++ b/ext/standard/tests/class_object/get_declared_traits_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing get_declared_traits() : error conditions ***\n"; // One argument echo "\n-- Testing get_declared_traits() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( get_declared_traits($extra_arg) ); echo "Done"; diff --git a/ext/standard/tests/file/userstreams_003.phpt b/ext/standard/tests/file/userstreams_003.phpt index 01a8efbf5c..9ee71f2666 100644 --- a/ext/standard/tests/file/userstreams_003.phpt +++ b/ext/standard/tests/file/userstreams_003.phpt @@ -19,9 +19,9 @@ class test_wrapper extends test_wrapper_base { var_dump($value); echo "ptrparam:\n"; var_dump($ptrparam); - echo "\$option === $option === " . $this->expected_option . ":\n";; + echo "\$option === $option === " . $this->expected_option . ":\n"; var_dump($option === $this->expected_option); - echo "\$value === $value === " . $this->expected_value. ":\n";; + echo "\$value === $value === " . $this->expected_value. ":\n"; var_dump($value === $this->expected_value); return $this->return_value; } diff --git a/ext/standard/tests/filters/bug22538.phpt b/ext/standard/tests/filters/bug22538.phpt index 438b5be31f..0f007e47bb 100644 --- a/ext/standard/tests/filters/bug22538.phpt +++ b/ext/standard/tests/filters/bug22538.phpt @@ -24,8 +24,8 @@ while (($cnt -= $str_len) > 0) { } $cnt = $size - ($str_len + $cnt); fclose($fp); -$fin = fopen($path1, "r") or die("Can not open $path1\n");; -$fout = fopen($path2, "w") or die("Can not open $path2\n");; +$fin = fopen($path1, "r") or die("Can not open $path1\n"); +$fout = fopen($path2, "w") or die("Can not open $path2\n"); stream_filter_append($fout, "string.rot13"); my_stream_copy_to_stream($fin, $fout); fclose($fout); diff --git a/ext/standard/tests/network/closelog_error.phpt b/ext/standard/tests/network/closelog_error.phpt index ad3fdf557d..442f9a6249 100644 --- a/ext/standard/tests/network/closelog_error.phpt +++ b/ext/standard/tests/network/closelog_error.phpt @@ -12,7 +12,7 @@ echo "*** Testing closelog() : error conditions ***\n"; // One argument echo "\n-- Testing closelog() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( closelog($extra_arg) ); ?> diff --git a/ext/wddx/tests/bug73173.phpt b/ext/wddx/tests/bug73173.phpt new file mode 100644 index 0000000000..00fe56e4b0 --- /dev/null +++ b/ext/wddx/tests/bug73173.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #73173: huge memleak when wddx_unserialize +--SKIPIF-- +<?php if (!extension_loaded("wddx")) print "skip"; ?> +--FILE-- +<?php + +$xml=<<<XML +<?xml version='1.0'?> +<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'> +<wddxPacket> +<var name=" +XML; + +$xml .= str_repeat('F',0x80000); + +$xml .= <<<XML +"> +</wddxPacket> +XML; +var_dump(wddx_deserialize($xml)); + +?> +--EXPECT-- +NULL diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index ccb90b0db3..6e105e8ab3 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -241,6 +241,9 @@ static int wddx_stack_destroy(wddx_stack *stack) } efree(stack->elements); } + if (stack->varname) { + efree(stack->varname); + } return SUCCESS; } /* }}} */ diff --git a/ext/zip/tests/bug38944.phpt b/ext/zip/tests/bug38944.phpt index 7cff60c984..ede6b67e77 100644 --- a/ext/zip/tests/bug38944.phpt +++ b/ext/zip/tests/bug38944.phpt @@ -7,7 +7,7 @@ Bug #38944 (newly created ZipArchive segfaults when accessing comment property) $arc_name = dirname(__FILE__)."/bug38944.zip"; $foo = new ZipArchive; -$foo->open($arc_name, ZIPARCHIVE::CREATE);; +$foo->open($arc_name, ZIPARCHIVE::CREATE); var_dump($foo->status); var_dump($foo->statusSys); diff --git a/ext/zip/tests/bug40228-mb.phpt b/ext/zip/tests/bug40228-mb.phpt index 109172d2d5..db9e2e90d5 100644 --- a/ext/zip/tests/bug40228-mb.phpt +++ b/ext/zip/tests/bug40228-mb.phpt @@ -7,7 +7,7 @@ Bug #40228 (extractTo does not create recursive empty path) $dest = dirname(__FILE__); $arc_name = $dest . "/bug40228私はガラスを食べられます.zip"; $zip = new ZipArchive; -$zip->open($arc_name, ZIPARCHIVE::CREATE);; +$zip->open($arc_name, ZIPARCHIVE::CREATE); $zip->extractTo($dest); if (is_dir($dest . '/test/empty')) { echo "Ok\n"; diff --git a/ext/zip/tests/bug40228.phpt b/ext/zip/tests/bug40228.phpt index fec2963639..2691b3b22f 100644 --- a/ext/zip/tests/bug40228.phpt +++ b/ext/zip/tests/bug40228.phpt @@ -7,7 +7,7 @@ Bug #40228 (extractTo does not create recursive empty path) $dest = dirname(__FILE__); $arc_name = $dest . "/bug40228.zip"; $zip = new ZipArchive; -$zip->open($arc_name, ZIPARCHIVE::CREATE);; +$zip->open($arc_name, ZIPARCHIVE::CREATE); $zip->extractTo($dest); if (is_dir($dest . '/test/empty')) { echo "Ok\n"; diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index d407455d33..e7f89055c7 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -48,6 +48,7 @@ typedef struct _php_zlib_buffer { typedef struct _php_zlib_context { z_stream Z; char *inflateDict; + size_t status; size_t inflateDictlen; php_zlib_buffer buffer; } php_zlib_context; diff --git a/ext/zlib/tests/bug73944.phpt b/ext/zlib/tests/bug73944.phpt new file mode 100644 index 0000000000..c4291afa4e --- /dev/null +++ b/ext/zlib/tests/bug73944.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #73944: Dictionary option of intflate_init() does not work +--FILE-- +<?php + +$in = inflate_init(ZLIB_ENCODING_RAW, array('dictionary' => str_repeat("\00", 32768))); +$a = inflate_add($in, file_get_contents(__DIR__.'/bug73944_fixture1')); +echo '1 block: '.strlen($a).PHP_EOL; + +$in = inflate_init(ZLIB_ENCODING_RAW, array('dictionary' => $a)); +$b = inflate_add($in, file_get_contents(__DIR__.'/bug73944_fixture2')); +echo '2 block: '.($b === false ? 'failed' : strlen($b)).PHP_EOL; + +?> +--EXPECTF-- +1 block: 32768 +2 block: 32768 diff --git a/ext/zlib/tests/bug73944_fixture1 b/ext/zlib/tests/bug73944_fixture1 Binary files differnew file mode 100644 index 0000000000..badc516288 --- /dev/null +++ b/ext/zlib/tests/bug73944_fixture1 diff --git a/ext/zlib/tests/bug73944_fixture2 b/ext/zlib/tests/bug73944_fixture2 Binary files differnew file mode 100644 index 0000000000..1a9abd6aee --- /dev/null +++ b/ext/zlib/tests/bug73944_fixture2 diff --git a/ext/zlib/tests/gztell_basic2.phpt b/ext/zlib/tests/gztell_basic2.phpt index d7a55895ef..ded3fbee7c 100644 --- a/ext/zlib/tests/gztell_basic2.phpt +++ b/ext/zlib/tests/gztell_basic2.phpt @@ -15,7 +15,7 @@ $sizes = array(7, 22, 54, 17, 27, 15, 1000); var_dump(gztell($h)); foreach ($sizes as $size) { - echo "bytes written=".gzwrite($h, str_repeat('1', $size))."\n";; + echo "bytes written=".gzwrite($h, str_repeat('1', $size))."\n"; echo "tell=".gztell($h)."\n"; } @@ -39,4 +39,4 @@ bytes written=15 tell=142 bytes written=1000 tell=1142 -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/zlib/tests/inflate_get_read_len.phpt b/ext/zlib/tests/inflate_get_read_len.phpt new file mode 100644 index 0000000000..54555fa7ba --- /dev/null +++ b/ext/zlib/tests/inflate_get_read_len.phpt @@ -0,0 +1,29 @@ +--TEST-- +inflate_get_read_len() +--SKIPIF-- +<?php if (!extension_loaded("zlib")) print "skip"; ?> +--FILE-- +<?php + +$uncompressed = "Hello world."; +$random_junk = str_repeat("qebsouesl", 128); + +$compressed = zlib_encode($uncompressed, ZLIB_ENCODING_DEFLATE); +$compressed_len = strlen($compressed); +$compressed .= $random_junk; + +$ctx = inflate_init(ZLIB_ENCODING_DEFLATE); +$buf = inflate_add($ctx, $compressed); +$detected_compressed_len = inflate_get_read_len($ctx); + +echo 'Status: ' . inflate_get_status($ctx) . "\n"; +echo 'Original compressed length: ' . $compressed_len . "\n"; +echo 'Detected compressed length: ' . $detected_compressed_len . "\n"; + +echo ($compressed_len == $detected_compressed_len) ? 'The lengths are equal.' : 'The lengths are unequal.'; +?> +--EXPECT-- +Status: 1 +Original compressed length: 20 +Detected compressed length: 20 +The lengths are equal. diff --git a/ext/zlib/tests/inflate_get_status.phpt b/ext/zlib/tests/inflate_get_status.phpt new file mode 100644 index 0000000000..01387b8122 --- /dev/null +++ b/ext/zlib/tests/inflate_get_status.phpt @@ -0,0 +1,60 @@ +--TEST-- +inflate_get_status() +--SKIPIF-- +<?php if (!extension_loaded("zlib")) print "skip"; ?> +--FILE-- +<?php + +$uncompressed = "Hello world."; +$random_junk = str_repeat("qebsouesl", 128); + +$compressed = zlib_encode($uncompressed, ZLIB_ENCODING_DEFLATE); +$compressed_len = strlen($compressed); +$compressed .= $random_junk; + +$ctx = inflate_init(ZLIB_ENCODING_DEFLATE); +$status = inflate_get_status($ctx); +$buf = ''; + +for ($i = 0; $status == ZLIB_OK; ++$i) +{ + $buf .= inflate_add($ctx, substr($compressed, $i, 1)); + echo '$i = ' . $i . ', '; + $status = inflate_get_status($ctx); + echo 'Status: ' . $status; + echo "\n"; +} + +echo '$buf = ' . $buf; +echo "\n\n"; + +echo "Adding more data should reset the stream and result in a Z_OK (ZLIB_OK) status.\n"; +inflate_add($ctx, substr($compressed, 0, 12)); +echo 'Status: ' . inflate_get_status($ctx); + +?> +--EXPECT-- +$i = 0, Status: 0 +$i = 1, Status: 0 +$i = 2, Status: 0 +$i = 3, Status: 0 +$i = 4, Status: 0 +$i = 5, Status: 0 +$i = 6, Status: 0 +$i = 7, Status: 0 +$i = 8, Status: 0 +$i = 9, Status: 0 +$i = 10, Status: 0 +$i = 11, Status: 0 +$i = 12, Status: 0 +$i = 13, Status: 0 +$i = 14, Status: 0 +$i = 15, Status: 0 +$i = 16, Status: 0 +$i = 17, Status: 0 +$i = 18, Status: 0 +$i = 19, Status: 1 +$buf = Hello world. + +Adding more data should reset the stream and result in a Z_OK (ZLIB_OK) status. +Status: 0 diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index dd0a1c23ef..3478fe536b 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -761,24 +761,6 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, switch (Z_TYPE_P(option_buffer)) { case IS_STRING: { zend_string *str = Z_STR_P(option_buffer); - size_t i; - zend_bool last_null = 1; - - for (i = 0; i < ZSTR_LEN(str); i++) { - if (ZSTR_VAL(str)[i]) { - last_null = 0; - } else { - if (last_null) { - php_error_docref(NULL, E_WARNING, "dictionary string must not contain empty entries (two consecutive NULL-bytes or one at the very beginning)"); - return 0; - } - last_null = 1; - } - } - if (!last_null) { - php_error_docref(NULL, E_WARNING, "dictionary string must be NULL-byte terminated (each dictionary entry has to be NULL-terminated)"); - } - *dict = emalloc(ZSTR_LEN(str)); memcpy(*dict, ZSTR_VAL(str), ZSTR_LEN(str)); *dictlen = ZSTR_LEN(str); @@ -886,6 +868,7 @@ PHP_FUNCTION(inflate_init) ctx->zfree = php_zlib_free; ((php_zlib_context *) ctx)->inflateDict = dict; ((php_zlib_context *) ctx)->inflateDictlen = dictlen; + ((php_zlib_context *) ctx)->status = Z_OK; if (encoding < 0) { encoding += 15 - window; @@ -894,6 +877,21 @@ PHP_FUNCTION(inflate_init) } if (Z_OK == inflateInit2(ctx, encoding)) { + if (encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0) { + php_zlib_context *php_ctx = (php_zlib_context *) ctx; + switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { + case Z_OK: + efree(php_ctx->inflateDict); + php_ctx->inflateDict = NULL; + break; + case Z_DATA_ERROR: + php_error_docref(NULL, E_WARNING, "dictionary does not match expected dictionary (incorrect adler32 hash)"); + efree(php_ctx->inflateDict); + php_ctx->inflateDict = NULL; + RETURN_FALSE; + EMPTY_SWITCH_DEFAULT_CASE() + } + } RETURN_RES(zend_register_resource(ctx, le_inflate)); } else { efree(ctx); @@ -938,6 +936,13 @@ PHP_FUNCTION(inflate_add) "flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH"); RETURN_FALSE; } + + /* Lazy-resetting the zlib stream so ctx->total_in remains available until the next inflate_add() call. */ + if (((php_zlib_context *) ctx)->status == Z_STREAM_END) + { + ((php_zlib_context *) ctx)->status = Z_OK; + inflateReset(ctx); + } if (in_len <= 0 && flush_type != Z_FINISH) { RETURN_EMPTY_STRING(); @@ -953,6 +958,8 @@ PHP_FUNCTION(inflate_add) status = inflate(ctx, flush_type); buffer_used = ZSTR_LEN(out) - ctx->avail_out; + ((php_zlib_context *) ctx)->status = status; /* Save status for exposing to userspace */ + switch (status) { case Z_OK: if (ctx->avail_out == 0) { @@ -965,7 +972,6 @@ PHP_FUNCTION(inflate_add) goto complete; } case Z_STREAM_END: - inflateReset(ctx); goto complete; case Z_BUF_ERROR: if (flush_type == Z_FINISH && ctx->avail_out == 0) { @@ -1014,6 +1020,48 @@ PHP_FUNCTION(inflate_add) } /* }}} */ +/* {{{ proto bool inflate_get_status(resource context) + Get decompression status, usually returns either ZLIB_OK or ZLIB_STREAM_END. */ +PHP_FUNCTION(inflate_get_status) +{ + zval *res; + z_stream *ctx; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "r", &res)) + { + RETURN_NULL(); + } + + if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { + php_error_docref(NULL, E_WARNING, "Invalid zlib.inflate resource"); + RETURN_FALSE; + } + + RETURN_LONG(((php_zlib_context *) ctx)->status); +} +/* }}} */ + +/* {{{ proto bool inflate_get_read_len(resource context) + Get number of bytes read so far. */ +PHP_FUNCTION(inflate_get_read_len) +{ + zval *res; + z_stream *ctx; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "r", &res)) + { + RETURN_NULL(); + } + + if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { + php_error_docref(NULL, E_WARNING, "Invalid zlib.inflate resource"); + RETURN_FALSE; + } + + RETURN_LONG(ctx->total_in); +} +/* }}} */ + /* {{{ proto resource deflate_init(int encoding[, array options]) Initialize an incremental deflate context using the specified encoding */ PHP_FUNCTION(deflate_init) @@ -1325,6 +1373,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_add, 0, 0, 2) ZEND_ARG_INFO(0, flush_behavior) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_get_status, 0, 0, 1) + ZEND_ARG_INFO(0, resource) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_get_read_len, 0, 0, 1) + ZEND_ARG_INFO(0, resource) +ZEND_END_ARG_INFO() + /* }}} */ /* {{{ php_zlib_functions[] */ @@ -1357,6 +1413,8 @@ static const zend_function_entry php_zlib_functions[] = { PHP_FE(deflate_add, arginfo_deflate_add) PHP_FE(inflate_init, arginfo_inflate_init) PHP_FE(inflate_add, arginfo_inflate_add) + PHP_FE(inflate_get_status, arginfo_inflate_get_status) + PHP_FE(inflate_get_read_len, arginfo_inflate_get_read_len) PHP_FE(ob_gzhandler, arginfo_ob_gzhandler) PHP_FE_END }; @@ -1472,6 +1530,16 @@ static PHP_MINIT_FUNCTION(zlib) REGISTER_STRING_CONSTANT("ZLIB_VERSION", ZLIB_VERSION, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ZLIB_VERNUM", ZLIB_VERNUM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_OK", Z_OK, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_STREAM_END", Z_STREAM_END, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_NEED_DICT", Z_NEED_DICT, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_ERRNO", Z_ERRNO, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_STREAM_ERROR", Z_STREAM_ERROR, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_DATA_ERROR", Z_DATA_ERROR, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_MEM_ERROR", Z_MEM_ERROR, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_BUF_ERROR", Z_BUF_ERROR, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("ZLIB_VERSION_ERROR", Z_VERSION_ERROR, CONST_CS|CONST_PERSISTENT); + REGISTER_INI_ENTRIES(); return SUCCESS; } diff --git a/main/main.c b/main/main.c index d6dee64e67..90dc78d8b4 100644 --- a/main/main.c +++ b/main/main.c @@ -908,7 +908,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ efree(docref_buf); } - if (PG(track_errors) && module_initialized && EG(valid_symbol_table) && + if (PG(track_errors) && module_initialized && EG(active) && (Z_TYPE(EG(user_error_handler)) == IS_UNDEF || !(EG(user_error_handler_error_reporting) & type))) { zval tmp; ZVAL_STRINGL(&tmp, buffer, buffer_len); @@ -1235,7 +1235,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u return; } - if (PG(track_errors) && module_initialized && EG(valid_symbol_table)) { + if (PG(track_errors) && module_initialized && EG(active)) { zval tmp; ZVAL_STRINGL(&tmp, buffer, buffer_len); diff --git a/main/php.h b/main/php.h index 116485a811..53926d2321 100644 --- a/main/php.h +++ b/main/php.h @@ -240,14 +240,6 @@ typedef unsigned int socklen_t; # endif #endif -#ifndef va_copy -# ifdef __va_copy -# define va_copy(ap1, ap2) __va_copy((ap1), (ap2)) -# else -# define va_copy(ap1, ap2) memcpy((&ap1), (&ap2), sizeof(va_list)) -# endif -#endif - #include "php_stdint.h" #include "zend_hash.h" diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 4cd6cca854..537021abd6 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1007,7 +1007,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zen /* fall through */ case PHP_STREAM_PERSISTENT_FAILURE: - efree(persistent_id);; + efree(persistent_id); return ret; } } diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index c9a946155a..8ab120a4b6 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1275,7 +1275,7 @@ static void fpm_conf_cleanup(int which, void *arg) /* {{{ */ static void fpm_conf_ini_parser_include(char *inc, void *arg) /* {{{ */ { char *filename; - int *error = (int *)arg;; + int *error = (int *)arg; #ifdef HAVE_GLOB glob_t g; #endif @@ -1490,17 +1490,17 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback switch(callback_type) { case ZEND_INI_PARSER_ENTRY: fpm_conf_ini_parser_entry(arg1, arg2, error); - break;; + break; case ZEND_INI_PARSER_SECTION: fpm_conf_ini_parser_section(arg1, error); - break;; + break; case ZEND_INI_PARSER_POP_ENTRY: fpm_conf_ini_parser_array(arg1, arg3, arg2, error); - break;; + break; default: zlog(ZLOG_ERROR, "[%s:%d] Unknown INI syntax", ini_filename, ini_lineno); *error = 1; - break;; + break; } } /* }}} */ diff --git a/tests/classes/array_access_001.phpt b/tests/classes/array_access_001.phpt index feed3fb8d9..784a886126 100644 --- a/tests/classes/array_access_001.phpt +++ b/tests/classes/array_access_001.phpt @@ -2,7 +2,7 @@ ZE2 ArrayAccess --FILE-- <?php -class object implements ArrayAccess { +class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); @@ -24,7 +24,7 @@ class object implements ArrayAccess { } } -$obj = new Object; +$obj = new ObjectOne; var_dump($obj->a); @@ -95,75 +95,75 @@ array(4) { int(4) } ===EMPTY=== -object::offsetExists(0) -object::offsetGet(0) +ObjectOne::offsetExists(0) +ObjectOne::offsetGet(0) bool(false) -object::offsetExists(1) -object::offsetGet(1) +ObjectOne::offsetExists(1) +ObjectOne::offsetGet(1) bool(false) -object::offsetExists(2) -object::offsetGet(2) +ObjectOne::offsetExists(2) +ObjectOne::offsetGet(2) bool(false) -object::offsetExists(4th) -object::offsetGet(4th) +ObjectOne::offsetExists(4th) +ObjectOne::offsetGet(4th) bool(false) -object::offsetExists(5th) +ObjectOne::offsetExists(5th) bool(true) -object::offsetExists(6) +ObjectOne::offsetExists(6) bool(true) ===isset=== -object::offsetExists(0) +ObjectOne::offsetExists(0) bool(true) -object::offsetExists(1) +ObjectOne::offsetExists(1) bool(true) -object::offsetExists(2) +ObjectOne::offsetExists(2) bool(true) -object::offsetExists(4th) +ObjectOne::offsetExists(4th) bool(true) -object::offsetExists(5th) +ObjectOne::offsetExists(5th) bool(false) -object::offsetExists(6) +ObjectOne::offsetExists(6) bool(false) ===offsetGet=== -object::offsetGet(0) +ObjectOne::offsetGet(0) string(3) "1st" -object::offsetGet(1) +ObjectOne::offsetGet(1) int(1) -object::offsetGet(2) +ObjectOne::offsetGet(2) string(3) "3rd" -object::offsetGet(4th) +ObjectOne::offsetGet(4th) int(4) -object::offsetGet(5th) +ObjectOne::offsetGet(5th) Notice: Undefined index: 5th in %sarray_access_001.php on line %d NULL -object::offsetGet(6) +ObjectOne::offsetGet(6) Notice: Undefined offset: 6 in %sarray_access_001.php on line %d NULL ===offsetSet=== WRITE 1 -object::offsetSet(1,Changed 1) -object::offsetGet(1) +ObjectOne::offsetSet(1,Changed 1) +ObjectOne::offsetGet(1) string(9) "Changed 1" WRITE 2 -object::offsetSet(4th,Changed 4th) -object::offsetGet(4th) +ObjectOne::offsetSet(4th,Changed 4th) +ObjectOne::offsetGet(4th) string(11) "Changed 4th" WRITE 3 -object::offsetSet(5th,Added 5th) -object::offsetGet(5th) +ObjectOne::offsetSet(5th,Added 5th) +ObjectOne::offsetGet(5th) string(9) "Added 5th" WRITE 4 -object::offsetSet(6,Added 6) -object::offsetGet(6) +ObjectOne::offsetSet(6,Added 6) +ObjectOne::offsetGet(6) string(7) "Added 6" -object::offsetGet(0) +ObjectOne::offsetGet(0) string(3) "1st" -object::offsetGet(2) +ObjectOne::offsetGet(2) string(3) "3rd" -object::offsetSet(6,changed 6) -object::offsetGet(6) +ObjectOne::offsetSet(6,changed 6) +ObjectOne::offsetGet(6) string(9) "changed 6" string(9) "changed 6" ===unset=== @@ -181,10 +181,10 @@ array(6) { [6]=> string(9) "changed 6" } -object::offsetUnset(2) -object::offsetUnset(4th) -object::offsetUnset(7) -object::offsetUnset(8th) +ObjectOne::offsetUnset(2) +ObjectOne::offsetUnset(4th) +ObjectOne::offsetUnset(7) +ObjectOne::offsetUnset(8th) array(4) { [0]=> string(3) "1st" diff --git a/tests/classes/array_access_002.phpt b/tests/classes/array_access_002.phpt index 68640c83f5..5e101914c0 100644 --- a/tests/classes/array_access_002.phpt +++ b/tests/classes/array_access_002.phpt @@ -2,7 +2,7 @@ ZE2 ArrayAccess::offsetSet without return --FILE-- <?php -class object implements ArrayAccess { +class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); @@ -24,7 +24,7 @@ class object implements ArrayAccess { } } -$obj = new Object; +$obj = new ObjectOne; var_dump($obj->a); @@ -95,75 +95,75 @@ array(4) { int(4) } ===EMPTY=== -object::offsetExists(0) -object::offsetGet(0) +ObjectOne::offsetExists(0) +ObjectOne::offsetGet(0) bool(false) -object::offsetExists(1) -object::offsetGet(1) +ObjectOne::offsetExists(1) +ObjectOne::offsetGet(1) bool(false) -object::offsetExists(2) -object::offsetGet(2) +ObjectOne::offsetExists(2) +ObjectOne::offsetGet(2) bool(false) -object::offsetExists(4th) -object::offsetGet(4th) +ObjectOne::offsetExists(4th) +ObjectOne::offsetGet(4th) bool(false) -object::offsetExists(5th) +ObjectOne::offsetExists(5th) bool(true) -object::offsetExists(6) +ObjectOne::offsetExists(6) bool(true) ===isset=== -object::offsetExists(0) +ObjectOne::offsetExists(0) bool(true) -object::offsetExists(1) +ObjectOne::offsetExists(1) bool(true) -object::offsetExists(2) +ObjectOne::offsetExists(2) bool(true) -object::offsetExists(4th) +ObjectOne::offsetExists(4th) bool(true) -object::offsetExists(5th) +ObjectOne::offsetExists(5th) bool(false) -object::offsetExists(6) +ObjectOne::offsetExists(6) bool(false) ===offsetGet=== -object::offsetGet(0) +ObjectOne::offsetGet(0) string(3) "1st" -object::offsetGet(1) +ObjectOne::offsetGet(1) int(1) -object::offsetGet(2) +ObjectOne::offsetGet(2) string(3) "3rd" -object::offsetGet(4th) +ObjectOne::offsetGet(4th) int(4) -object::offsetGet(5th) +ObjectOne::offsetGet(5th) Notice: Undefined index: 5th in %sarray_access_002.php on line %d NULL -object::offsetGet(6) +ObjectOne::offsetGet(6) Notice: Undefined offset: 6 in %sarray_access_002.php on line %d NULL ===offsetSet=== WRITE 1 -object::offsetSet(1,Changed 1) -object::offsetGet(1) +ObjectOne::offsetSet(1,Changed 1) +ObjectOne::offsetGet(1) string(9) "Changed 1" WRITE 2 -object::offsetSet(4th,Changed 4th) -object::offsetGet(4th) +ObjectOne::offsetSet(4th,Changed 4th) +ObjectOne::offsetGet(4th) string(11) "Changed 4th" WRITE 3 -object::offsetSet(5th,Added 5th) -object::offsetGet(5th) +ObjectOne::offsetSet(5th,Added 5th) +ObjectOne::offsetGet(5th) string(9) "Added 5th" WRITE 4 -object::offsetSet(6,Added 6) -object::offsetGet(6) +ObjectOne::offsetSet(6,Added 6) +ObjectOne::offsetGet(6) string(7) "Added 6" -object::offsetGet(0) +ObjectOne::offsetGet(0) string(3) "1st" -object::offsetGet(2) +ObjectOne::offsetGet(2) string(3) "3rd" -object::offsetSet(6,changed 6) -object::offsetGet(6) +ObjectOne::offsetSet(6,changed 6) +ObjectOne::offsetGet(6) string(9) "changed 6" string(9) "changed 6" ===unset=== @@ -181,10 +181,10 @@ array(6) { [6]=> string(9) "changed 6" } -object::offsetUnset(2) -object::offsetUnset(4th) -object::offsetUnset(7) -object::offsetUnset(8th) +ObjectOne::offsetUnset(2) +ObjectOne::offsetUnset(4th) +ObjectOne::offsetUnset(7) +ObjectOne::offsetUnset(8th) array(4) { [0]=> string(3) "1st" diff --git a/tests/classes/array_access_003.phpt b/tests/classes/array_access_003.phpt index 3e631125e7..8924d1575f 100644 --- a/tests/classes/array_access_003.phpt +++ b/tests/classes/array_access_003.phpt @@ -4,7 +4,7 @@ ZE2 ArrayAccess::offsetGet ambiguties error_reporting=4095 --FILE-- <?php -class object implements ArrayAccess { +class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); @@ -37,7 +37,7 @@ class object implements ArrayAccess { } } -$obj = new Object; +$obj = new ObjectOne; var_dump($obj[1]); var_dump($obj[2]); @@ -47,13 +47,13 @@ var_dump($obj[2]); ?> ===DONE=== --EXPECTF-- -object::offsetGet(1) +ObjectOne::offsetGet(1) string(6) "fooBar" -object::offsetGet(2) +ObjectOne::offsetGet(2) int(1) -object::offsetGet(2) +ObjectOne::offsetGet(2) -Notice: Indirect modification of overloaded element of object has no effect in %sarray_access_003.php on line 39 -object::offsetGet(2) +Notice: Indirect modification of overloaded element of ObjectOne has no effect in %sarray_access_003.php on line 39 +ObjectOne::offsetGet(2) int(1) ===DONE=== diff --git a/tests/classes/array_access_004.phpt b/tests/classes/array_access_004.phpt index 787496707c..22566937f2 100644 --- a/tests/classes/array_access_004.phpt +++ b/tests/classes/array_access_004.phpt @@ -2,7 +2,7 @@ ZE2 ArrayAccess::offsetGet ambiguties --FILE-- <?php -class object implements ArrayAccess { +class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); @@ -35,7 +35,7 @@ class object implements ArrayAccess { } } -$obj = new Object; +$obj = new ObjectOne; var_dump($obj[1]); var_dump($obj[2]); @@ -45,13 +45,13 @@ var_dump($obj[2]); ?> ===DONE=== --EXPECTF-- -object::offsetGet(1) +ObjectOne::offsetGet(1) string(6) "fooBar" -object::offsetGet(2) +ObjectOne::offsetGet(2) int(1) -object::offsetGet(2) +ObjectOne::offsetGet(2) -Notice: Indirect modification of overloaded element of object has no effect in %sarray_access_004.php on line 39 -object::offsetGet(2) +Notice: Indirect modification of overloaded element of ObjectOne has no effect in %sarray_access_004.php on line 39 +ObjectOne::offsetGet(2) int(1) ===DONE=== diff --git a/tests/output/ob_clean_error_001.phpt b/tests/output/ob_clean_error_001.phpt index a1b9886f3e..8060c2be8b 100644 --- a/tests/output/ob_clean_error_001.phpt +++ b/tests/output/ob_clean_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing ob_clean() : error conditions ***\n"; // One argument echo "\n-- Testing ob_clean() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( ob_clean($extra_arg) ); echo "Done"; diff --git a/tests/output/ob_end_flush_error_001.phpt b/tests/output/ob_end_flush_error_001.phpt index 7675f009e0..2cd9a64e0d 100644 --- a/tests/output/ob_end_flush_error_001.phpt +++ b/tests/output/ob_end_flush_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing ob_end_flush() : error conditions ***\n"; // One argument echo "\n-- Testing ob_end_flush() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( ob_end_flush($extra_arg) ); echo "Done"; diff --git a/tests/output/ob_flush_error_001.phpt b/tests/output/ob_flush_error_001.phpt index f98504006a..f24a19b8ce 100644 --- a/tests/output/ob_flush_error_001.phpt +++ b/tests/output/ob_flush_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing ob_flush() : error conditions ***\n"; // One argument echo "\n-- Testing ob_flush() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( ob_flush($extra_arg) ); echo "Done"; diff --git a/tests/output/ob_get_level_error_001.phpt b/tests/output/ob_get_level_error_001.phpt index 4719bdd72e..9694da54a0 100644 --- a/tests/output/ob_get_level_error_001.phpt +++ b/tests/output/ob_get_level_error_001.phpt @@ -12,7 +12,7 @@ echo "*** Testing ob_get_level() : error conditions ***\n"; // One argument echo "\n-- Testing ob_get_level() function with one argument --\n"; -$extra_arg = 10;; +$extra_arg = 10; var_dump( ob_get_level($extra_arg) ); echo "Done"; |
