php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73629 SplDoublyLinkedList::setIteratorMode masks intern flags
Submitted: 2016-11-30 15:50 UTC Modified: 2017-09-20 14:01 UTC
From: j dot jeising at gmail dot com Assigned: cmb (profile)
Status: Closed Package: SPL related
PHP Version: 7.1Git-2016-11-30 (Git) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: j dot jeising at gmail dot com
New email:
PHP Version: OS:

 

 [2016-11-30 15:50 UTC] j dot jeising at gmail dot com
Description:
------------
When SplDoublyLinkedList::setIteratorMode is called it overwrites its internal flag SPL_DLLIST_IT_FIX.

This allows mode changes for SplStack/SplQueue which otherwise would result in an exception.

This is different from #63175, as it is not related to user defined flags.

A proposed patch is attached.

Test script:
---------------
<?php

$q = new SplQueue();
$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
$q->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);

$r = new SplQueue();
$r->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);

Expected result:
----------------
RuntimeException: Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen in test.php on line 5
RuntimeException: Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen in test.php on line 8

Actual result:
--------------
RuntimeException: Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen in test.php on line 8

Patches

fix-iterator-mask.patch (last revision 2016-11-30 15:50 UTC by j dot jeising at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-20 13:03 UTC] cmb@php.net
-Status: Open +Status: Analyzed
 [2017-09-20 13:03 UTC] cmb@php.net
Thanks for reporting this issue, and the fine analysis!

Indeed, this is a bug, see <https://3v4l.org/RhYP0>.
 [2017-09-20 14:01 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=eedc060c92e12e054a542dc7156e31cec935a8d6
Log: Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags)
 [2017-09-20 14:01 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 [2017-09-20 14:01 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC