Skip to content

Commit 13e9222

Browse files
committed
Fixed bug #78436
1 parent 514be3f commit 13e9222

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fixed bug #78441 (Parse error due to heredoc identifier followed by digit).
1111
(cmb)
1212

13+
- SPL:
14+
. Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode).
15+
(Nikita)
16+
1317
22 Aug 2019, PHP 7.4.0beta4
1418

1519
- Core:

ext/spl/spl_heap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ static void spl_pqueue_extract_helper(zval *result, zval *value, int flags) /* {
144144
spl_pqueue_elem *elem = Z_PTR_P(value);
145145
if ((flags & SPL_PQUEUE_EXTR_BOTH) == SPL_PQUEUE_EXTR_BOTH) {
146146
array_init(result);
147+
Z_TRY_ADDREF(elem->data);
147148
add_assoc_zval_ex(result, "data", sizeof("data") - 1, &elem->data);
149+
Z_TRY_ADDREF(elem->priority);
148150
add_assoc_zval_ex(result, "priority", sizeof("priority") - 1, &elem->priority);
149151
return;
150152
}

ext/spl/tests/bug78436.phpt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--TEST--
2+
Bug #78436: Missing addref in SplPriorityQueue EXTR_BOTH mode
3+
--FILE--
4+
<?php
5+
6+
$pq = new SplPriorityQueue();
7+
$pq->insert(new stdClass, 1);
8+
var_dump($pq);
9+
var_dump($pq);
10+
11+
?>
12+
--EXPECT--
13+
object(SplPriorityQueue)#1 (3) {
14+
["flags":"SplPriorityQueue":private]=>
15+
int(1)
16+
["isCorrupted":"SplPriorityQueue":private]=>
17+
bool(false)
18+
["heap":"SplPriorityQueue":private]=>
19+
array(1) {
20+
[0]=>
21+
array(2) {
22+
["data"]=>
23+
object(stdClass)#2 (0) {
24+
}
25+
["priority"]=>
26+
int(1)
27+
}
28+
}
29+
}
30+
object(SplPriorityQueue)#1 (3) {
31+
["flags":"SplPriorityQueue":private]=>
32+
int(1)
33+
["isCorrupted":"SplPriorityQueue":private]=>
34+
bool(false)
35+
["heap":"SplPriorityQueue":private]=>
36+
array(1) {
37+
[0]=>
38+
array(2) {
39+
["data"]=>
40+
object(stdClass)#2 (0) {
41+
}
42+
["priority"]=>
43+
int(1)
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)