-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RecursiveIteratorIterator segfault for invalid aggregate
The code was assuming that the returned value is an object. Reuse the logic from IteratorIterator.
- Loading branch information
Showing
2 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
ext/spl/tests/RecursiveIteratorIterator_invalid_aggregate.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
RecursiveIteratorIterator constructor should thrown if IteratorAggregate does not return Iterator | ||
--FILE-- | ||
<?php | ||
|
||
class MyIteratorAggregate implements IteratorAggregate { | ||
function getIterator() { | ||
return null; | ||
} | ||
} | ||
|
||
try { | ||
new RecursiveIteratorIterator(new MyIteratorAggregate); | ||
} catch (LogicException $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
MyIteratorAggregate::getIterator() must return an object that implements Traversable |