1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 01:48:26 +02:00

fix bad formatted "undefined offset" notice when key is negative

This commit is contained in:
Márcio Almada
2015-06-09 03:56:34 -03:00
committed by Nikita Popov
parent 51dbf73954
commit fdda34e0bc
2 changed files with 23 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
--TEST--
Ensure "undefined offset" notice formats message corectly when undefined key is negative
--FILE--
<?php
[][-1];
[][-1.1];
(new ArrayObject)[-1];
(new ArrayObject)[-1.1];
echo "Done\n";
?>
--EXPECTF--
Notice: Undefined offset: -1 in %s on line 3
Notice: Undefined offset: -1 in %s on line 4
Notice: Undefined offset: -1 in %s on line 5
Notice: Undefined offset: -1 in %s on line 6
Done
+2 -2
View File
@@ -1438,14 +1438,14 @@ num_index:
if (retval == NULL) {
switch (type) {
case BP_VAR_R:
zend_error(E_NOTICE,"Undefined offset: " ZEND_ULONG_FMT, hval);
zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, hval);
/* break missing intentionally */
case BP_VAR_UNSET:
case BP_VAR_IS:
retval = &EG(uninitialized_zval);
break;
case BP_VAR_RW:
zend_error(E_NOTICE,"Undefined offset: " ZEND_ULONG_FMT, hval);
zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, hval);
/* break missing intentionally */
case BP_VAR_W:
retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));