com php-src: Add opcodes to zend_wrong_string_offset( ): Zend/tests/string_offset_errors.phpt Zend/zend _execute.c
ext/opcache/Optimizer/zend_inference.c

From: Date: Sun, 10 Jul 2016 13:15:34 +0000
Subject: com php-src: Add opcodes to zend_wrong_string_offset( ): Zend/tests/string_offset_errors.phpt Zend/zend _execute.c
ext/opcache/Optimizer/zend_inference.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92900@lists.php.net to get a copy of this message
Commit: 5f6effed4323191d00bbdb48271a390d366e539d Author: Nikita Popov <nikic@php.net> Sun, 10 Jul 2016 15:13:21 +0200 Parents: 445cb529b2cae65cbe00c4d49ee5c78e017e1b15 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5f6effed4323191d00bbdb48271a390d366e539d Log: Add opcodes to zend_wrong_string_offset() Changed paths: A Zend/tests/string_offset_errors.phpt M Zend/zend_execute.c M ext/opcache/Optimizer/zend_inference.c Diff: diff --git a/Zend/tests/string_offset_errors.phpt b/Zend/tests/string_offset_errors.phpt new file mode 100644 index 0000000..b709408 --- /dev/null +++ b/Zend/tests/string_offset_errors.phpt @@ -0,0 +1,27 @@ +--TEST-- +Some string offset errors +--FILE-- +<?php + +function &test() : string { + $str = "foo"; + return $str[0]; +} + +try { + test(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +try { + $str = "foo"; + $str[0] =& $str[1]; +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Cannot return string offsets by reference +Cannot create references to/from string offsets diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 7c8621f..d1c7391 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1262,9 +1262,11 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(void) case ZEND_ASSIGN_REF: case ZEND_ADD_ARRAY_ELEMENT: case ZEND_INIT_ARRAY: + case ZEND_MAKE_REF: msg = "Cannot create references to/from string offsets"; break; case ZEND_RETURN_BY_REF: + case ZEND_VERIFY_RETURN_TYPE: msg = "Cannot return string offsets by reference"; break; case ZEND_UNSET_DIM: diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 4760076..c8dd100 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -3229,6 +3229,7 @@ static void zend_update_type_info(const zend_op_array *op_array, case ZEND_ADD_ARRAY_ELEMENT: case ZEND_RETURN_BY_REF: case ZEND_VERIFY_RETURN_TYPE: + case ZEND_MAKE_REF: tmp |= MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; break; case ZEND_PRE_INC:

« previous php.cvs (#92900) next »