com php-src: Fixed bug #67693 - incorrect push to the empty array: ext/standard/array.c ext/standard/tests/array/bug67693.phpt
| From: | Tjerk Anne Meesters | Date: | Wed, 30 Jul 2014 10:15:14 +0000 |
| Subject: | com php-src: Fixed bug #67693 - incorrect push to the empty array: ext/standard/array.c ext/standard/tests/array/bug67693.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79666@lists.php.net to get a copy of this message | ||
Commit: da3add26cf7d9eec2023fdd3e52550ccb49aa74c
Author: Tjerk Meesters <datibbaw@php.net> Wed, 30 Jul 2014 17:54:09 +0800
Parents: ab6c1d21f9cec83eac21a8930fdfc5acb5850da8
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=da3add26cf7d9eec2023fdd3e52550ccb49aa74c
Log:
Fixed bug #67693 - incorrect push to the empty array
Bugs:
https://bugs.php.net/67693
Changed paths:
M ext/standard/array.c
A ext/standard/tests/array/bug67693.phpt
Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index c2efca5..06cac0e 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2020,7 +2020,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
if (should_rehash) {
zend_hash_rehash(Z_ARRVAL_P(stack));
}
- } else if (!key_len && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
+ } else if (!key_len && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index
>= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
Z_ARRVAL_P(stack)->nNextFreeElement = Z_ARRVAL_P(stack)->nNextFreeElement - 1;
}
diff --git a/ext/standard/tests/array/bug67693.phpt b/ext/standard/tests/array/bug67693.phpt
new file mode 100644
index 0000000..516436c
--- /dev/null
+++ b/ext/standard/tests/array/bug67693.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #67693 - incorrect push to empty array
+--FILE--
+<?php
+
+$array = array(-1 => 0);
+
+array_pop($array);
+
+array_push($array, 0);
+array_push($array, 0);
+
+var_dump($array);
+
+echo"\nDone";
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(0)
+}
+
+Done