summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-09-28 22:38:47 +0200
committerNikita Popov <nikic@php.net>2016-09-28 22:38:47 +0200
commit97066792b77578caf2265479d2ee75715a6ef958 (patch)
tree513a6bd2248d518b9461c61c4fb1c8cdc16b8502 /Zend
parenta61bc294db3a1951c9bca5b90ae056a5b3aa8622 (diff)
parent437942d972c15e17539e9029205a1198bb597b90 (diff)
downloadphp-git-97066792b77578caf2265479d2ee75715a6ef958.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/array_literal_next_element_error.phpt16
-rw-r--r--Zend/zend_vm_def.h5
-rw-r--r--Zend/zend_vm_execute.h80
3 files changed, 84 insertions, 17 deletions
diff --git a/Zend/tests/array_literal_next_element_error.phpt b/Zend/tests/array_literal_next_element_error.phpt
new file mode 100644
index 0000000000..59ffeb02c7
--- /dev/null
+++ b/Zend/tests/array_literal_next_element_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Next free element may overflow in array literals
+--FILE--
+<?php
+
+$i = PHP_INT_MAX;
+$array = [$i => 42, new stdClass];
+var_dump($array);
+
+?>
+--EXPECTF--
+Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
+array(1) {
+ [%d]=>
+ int(42)
+}
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 28a8811b02..67f4f4b150 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -5286,7 +5286,10 @@ ZEND_VM_C_LABEL(num_index):
}
FREE_OP2();
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 4cb7e56cb3..29fcf61b16 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -5865,7 +5865,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -7688,7 +7691,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -9737,7 +9743,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -11642,7 +11651,10 @@ num_index:
}
zval_ptr_dtor_nogc(free_op2);
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -13642,7 +13654,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -14335,7 +14350,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -14861,7 +14879,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -15383,7 +15404,10 @@ num_index:
}
zval_ptr_dtor_nogc(free_op2);
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -19999,7 +20023,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -21869,7 +21896,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -24760,7 +24790,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -27595,7 +27628,10 @@ num_index:
}
zval_ptr_dtor_nogc(free_op2);
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -39738,7 +39774,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -42626,7 +42665,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -46712,7 +46754,10 @@ num_index:
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
@@ -50669,7 +50714,10 @@ num_index:
}
zval_ptr_dtor_nogc(free_op2);
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
+ if (!zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(expr_ptr);
+ }
}
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}