[Issue 22359] New: joiner over an empty forward range object liable to segfault
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 6 01:51:05 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22359
Issue ID: 22359
Summary: joiner over an empty forward range object liable to
segfault
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: destructionator at gmail.com
There's some old bugs from a decade ago that are apparently related but not
quite the same as their test case is one item deep and this requires something
two items deep. Behold:
------
import std.range;
ForwardRange!int fnFlatten(int[][] r)
{
import std.range : inputRangeObject;
import std.algorithm : map, joiner;
auto range = inputRangeObject(r);
return range.map!(a =>inputRangeObject(a)).joiner.inputRangeObject;
}
void main() {
auto f = fnFlatten([[]]);
f.save();
}
------
In the `private enum popFrontEmptyElement` of joiner, there's a `_current =
typeof(_current).init;`
If _current is some kind of class, that's null. Then when you call `save` on
it, it is a null this deref.
--
More information about the Digitalmars-d-bugs
mailing list