Skip to content

Commit eedc060

Browse files
committed
Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags)
We must not overwrite the SPL_DLLIST_IT_FIX flag when changing the iterator mode.
1 parent 9641586 commit eedc060

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2017 PHP 7.0.25
44

5-
5+
- SPL:
6+
. Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags).
7+
(J. Jeising, cmb)
68

79
28 Sep 2017 PHP 7.0.24
810

ext/spl/spl_dllist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ SPL_METHOD(SplDoublyLinkedList, setIteratorMode)
733733
return;
734734
}
735735

736-
intern->flags = value & SPL_DLLIST_IT_MASK;
736+
intern->flags = value & SPL_DLLIST_IT_MASK | intern->flags & SPL_DLLIST_IT_FIX;
737737

738738
RETURN_LONG(intern->flags);
739739
}

ext/spl/tests/bug73629.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags)
3+
--FILE--
4+
<?php
5+
$q = new SplQueue();
6+
try {
7+
$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
8+
} catch (Exception $e) {
9+
echo 'unexpected exception: ' . $e->getMessage() . "\n";
10+
}
11+
try {
12+
$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
13+
} catch (Exception $e) {
14+
echo 'expected exception: ' . $e->getMessage() . "\n";
15+
}
16+
?>
17+
===DONE===
18+
--EXPECTF--
19+
expected exception: Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
20+
===DONE===

0 commit comments

Comments
 (0)