August 01, 2018 [Issue 19133] New: core.exception.rangeerror@std/file.d(3812): | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19133 Issue ID: 19133 Summary: core.exception.rangeerror@std/file.d(3812): Product: D Version: D2 Hardware: x86_64 OS: Solaris Status: NEW Severity: regression Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: crayolist@gmail.com On Solaris dirent is defined druntime/src/core/sys/posix/dirent.d like this; else version (Solaris) { struct dirent { ino_t d_ino; off_t d_off; ushort d_reclen; char[1] d_name; } This commit; Commit: 5e88b67808022adba692451791422cb9fd58b490 [5e88b67] Parents: 0ff1cfe045 Author: Alexandru Jercaianu <alex.jercaianu@gmail.com> Date: Thursday, October 5, 2017 1:20:39 PM Committer: Alexandru Jercaianu minor code refactoring introduced a regression with the following change; - private this(string path, core.sys.posix.dirent.dirent* fd) @safe + private this(string path, core.sys.posix.dirent.dirent* fd) @trusted { import std.path : buildPath; - static auto trustedStrlen(const char* str) @trusted - { - return core.stdc.string.strlen(str); - } - - immutable len = trustedStrlen(&fd.d_name[0]); + fd.d_name[$ - 1] = 0; + immutable len = strlen(&fd.d_name[0]); _name = buildPath(path, fd.d_name[0 .. len]); Specifically the line fd.d_name[$ - 1] = 0; is equivalent to fd.d_name[0] = 0, thus len is always 0. -- |
Copyright © 1999-2021 by the D Language Foundation