com php-src: Fixed bug #78436: NEWS ext/spl/spl_heap.c ex t/spl/tests/bug78436.phpt
| From: | Nikita Popov | Date: | Fri, 23 Aug 2019 13:27:28 +0000 |
| Subject: | com php-src: Fixed bug #78436: NEWS ext/spl/spl_heap.c ex t/spl/tests/bug78436.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108007@lists.php.net to get a copy of this message | ||
Commit: 13e92223c0c102b33b775ff1e4f27bcca72f0eb9
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 23 Aug 2019 15:27:28 +0200
Parents: 514be3ff8723628058afd70f75f2501b1797cccf
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=13e92223c0c102b33b775ff1e4f27bcca72f0eb9
Log:
Fixed bug #78436
Bugs:
https://bugs.php.net/78436
Changed paths:
M NEWS
M ext/spl/spl_heap.c
A ext/spl/tests/bug78436.phpt
Diff:
diff --git a/NEWS b/NEWS
index 8fa0367..45df257 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ PHP NEWS
. Fixed bug #78441 (Parse error due to heredoc identifier followed by digit).
(cmb)
+- SPL:
+ . Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode).
+ (Nikita)
+
22 Aug 2019, PHP 7.4.0beta4
- Core:
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index 6de7adb..af0043b 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -144,7 +144,9 @@ static void spl_pqueue_extract_helper(zval *result, zval *value, int flags) /* {
spl_pqueue_elem *elem = Z_PTR_P(value);
if ((flags & SPL_PQUEUE_EXTR_BOTH) == SPL_PQUEUE_EXTR_BOTH) {
array_init(result);
+ Z_TRY_ADDREF(elem->data);
add_assoc_zval_ex(result, "data", sizeof("data") - 1, &elem->data);
+ Z_TRY_ADDREF(elem->priority);
add_assoc_zval_ex(result, "priority", sizeof("priority") - 1,
&elem->priority);
return;
}
diff --git a/ext/spl/tests/bug78436.phpt b/ext/spl/tests/bug78436.phpt
new file mode 100644
index 0000000..8b978d5
--- /dev/null
+++ b/ext/spl/tests/bug78436.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #78436: Missing addref in SplPriorityQueue EXTR_BOTH mode
+--FILE--
+<?php
+
+$pq = new SplPriorityQueue();
+$pq->insert(new stdClass, 1);
+var_dump($pq);
+var_dump($pq);
+
+?>
+--EXPECT--
+object(SplPriorityQueue)#1 (3) {
+ ["flags":"SplPriorityQueue":private]=>
+ int(1)
+ ["isCorrupted":"SplPriorityQueue":private]=>
+ bool(false)
+ ["heap":"SplPriorityQueue":private]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ ["data"]=>
+ object(stdClass)#2 (0) {
+ }
+ ["priority"]=>
+ int(1)
+ }
+ }
+}
+object(SplPriorityQueue)#1 (3) {
+ ["flags":"SplPriorityQueue":private]=>
+ int(1)
+ ["isCorrupted":"SplPriorityQueue":private]=>
+ bool(false)
+ ["heap":"SplPriorityQueue":private]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ ["data"]=>
+ object(stdClass)#2 (0) {
+ }
+ ["priority"]=>
+ int(1)
+ }
+ }
+}