From eedc060c92e12e054a542dc7156e31cec935a8d6 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 20 Sep 2017 15:36:50 +0200 Subject: [PATCH] Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags) We must not overwrite the SPL_DLLIST_IT_FIX flag when changing the iterator mode. --- NEWS | 4 +++- ext/spl/spl_dllist.c | 2 +- ext/spl/tests/bug73629.phpt | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 ext/spl/tests/bug73629.phpt diff --git a/NEWS b/NEWS index 87933990e1..acc2648b38 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2017 PHP 7.0.25 - +- SPL: + . Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags). + (J. Jeising, cmb) 28 Sep 2017 PHP 7.0.24 diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index c205de5fed..db9fa838c8 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -733,7 +733,7 @@ SPL_METHOD(SplDoublyLinkedList, setIteratorMode) return; } - intern->flags = value & SPL_DLLIST_IT_MASK; + intern->flags = value & SPL_DLLIST_IT_MASK | intern->flags & SPL_DLLIST_IT_FIX; RETURN_LONG(intern->flags); } diff --git a/ext/spl/tests/bug73629.phpt b/ext/spl/tests/bug73629.phpt new file mode 100644 index 0000000000..5b6587c685 --- /dev/null +++ b/ext/spl/tests/bug73629.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags) +--FILE-- +setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); +} catch (Exception $e) { + echo 'unexpected exception: ' . $e->getMessage() . "\n"; +} +try { + $q->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); +} catch (Exception $e) { + echo 'expected exception: ' . $e->getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +expected exception: Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen +===DONE=== -- 2.50.0