Skip to content

Commit 497fadc

Browse files
committed
Fix leak in SplDoublyLinkedList::add()
1 parent 02db708 commit 497fadc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ext/spl/spl_dllist.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,8 +1215,6 @@ PHP_METHOD(SplDoublyLinkedList, add)
12151215
element->prev = elem;
12161216

12171217
intern->llist->count++;
1218-
1219-
Z_TRY_ADDREF(elem->data);
12201218
}
12211219
} /* }}} */
12221220

ext/spl/tests/dllist_013.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ echo $dll->pop()."\n";
2929
echo $dll->pop()."\n";
3030
echo $dll->pop()."\n";
3131
echo $dll->pop()."\n";
32+
33+
// Test refcounted value
34+
$str = "foo";
35+
$str .= "bar";
36+
$dll->add(0, null);
37+
$dll->add(0, $str);
38+
var_dump($dll->shift());
39+
3240
?>
3341
--EXPECT--
3442
Exception: SplDoublyLinkedList::add(): Argument #1 ($index) is out of range
@@ -40,3 +48,4 @@ Exception: SplDoublyLinkedList::add(): Argument #1 ($index) is out of range
4048
3
4149
2
4250
1
51+
string(6) "foobar"

0 commit comments

Comments
 (0)