dmitry Fri, 22 Oct 2010 11:05:22 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=304612
Log: Fixed crash on attempt to insert reference to string offset into an array Changed paths: A php/php-src/trunk/Zend/tests/str_offset_002.phpt U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h
Added: php/php-src/trunk/Zend/tests/str_offset_002.phpt =================================================================== --- php/php-src/trunk/Zend/tests/str_offset_002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/str_offset_002.phpt 2010-10-22 11:05:22 UTC (rev 304612) @@ -0,0 +1,9 @@ +--TEST-- +string offset 002 +--FILE-- +<?php +$a = "aaa"; +$x = array(&$a[1]); +?> +--EXPECTF-- +Fatal error: Cannot create references to/from string offsets in %sstr_offset_002.php on line 3 Modified: php/php-src/trunk/Zend/zend_vm_def.h =================================================================== --- php/php-src/trunk/Zend/zend_vm_def.h 2010-10-22 10:18:31 UTC (rev 304611) +++ php/php-src/trunk/Zend/zend_vm_def.h 2010-10-22 11:05:22 UTC (rev 304612) @@ -3463,6 +3463,9 @@ if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); + if (OP1_TYPE == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); Modified: php/php-src/trunk/Zend/zend_vm_execute.h =================================================================== --- php/php-src/trunk/Zend/zend_vm_execute.h 2010-10-22 10:18:31 UTC (rev 304611) +++ php/php-src/trunk/Zend/zend_vm_execute.h 2010-10-22 11:05:22 UTC (rev 304612) @@ -3367,6 +3367,9 @@ if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -4062,6 +4065,9 @@ if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -4724,6 +4730,9 @@ if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -5235,6 +5244,9 @@ if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -5966,6 +5978,9 @@ if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -7597,6 +7612,9 @@ if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -8254,6 +8272,9 @@ if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -8918,6 +8939,9 @@ if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -9316,6 +9340,9 @@ if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -9970,6 +9997,9 @@ if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = NULL; + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -13180,6 +13210,9 @@ if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -15227,6 +15260,9 @@ if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -17336,6 +17372,9 @@ if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -18551,6 +18590,9 @@ if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -20386,6 +20428,9 @@ if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -28499,6 +28544,9 @@ if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -30420,6 +30468,9 @@ if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -32402,6 +32453,9 @@ if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -33498,6 +33552,9 @@ if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); @@ -35189,6 +35246,9 @@ if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); + } SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php