summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r--Zend/zend_execute.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index b249b37871..5309c51439 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1190,7 +1190,28 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container
zend_error_noreturn(E_ERROR, "[] operator not supported for strings");
}
- if (dim->type != IS_LONG) {
+ if (Z_TYPE_P(dim) == IS_STRING) {
+ char *strval;
+ long lval;
+
+ strval = Z_STRVAL_P(dim);
+ if (is_numeric_string(strval, Z_STRLEN_P(dim), &lval, NULL, 0) == IS_LONG) {
+ ZVAL_LONG(&tmp, lval);
+ dim = &tmp;
+ } else {
+ if (type != BP_VAR_IS && type != BP_VAR_UNSET) {
+ zend_error(E_NOTICE, "Trying to get string index from a string");
+ }
+ if (result) {
+ result->var.ptr_ptr = &EG(error_zval_ptr);
+ PZVAL_LOCK(*result->var.ptr_ptr);
+ if (type == BP_VAR_R || type == BP_VAR_IS) {
+ AI_USE_PTR(result->var);
+ }
+ }
+ return;
+ }
+ } else if (dim->type != IS_LONG) {
tmp = *dim;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);