digitalmars.D.bugs - [Issue 15586] New: std.utf.toUTF8() segfaults when fed an invalid
- via Digitalmars-d-bugs (28/28) Jan 20 2016 https://issues.dlang.org/show_bug.cgi?id=15586
https://issues.dlang.org/show_bug.cgi?id=15586 Issue ID: 15586 Summary: std.utf.toUTF8() segfaults when fed an invalid dchar Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: thomas.bockman gmail.com Repro: void main() { import std.utf : toUTF8; char[4] buf = void; auto b = toUTF8(buf, cast(dchar)0x110000); import std.stdio; writeln(b); } Cause: toUTF8() asserts that invalid dchars just *don't exist*. It then proceeds to return *nothing at all* when fed one, which violates memory safety. Because of https://issues.dlang.org/show_bug.cgi?id=15585 the compiler may optimize away attempts to fix this entirely. --
Jan 20 2016