[Issue 19133] New: core.exception.rangeerror at std/file.d(3812):

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 1 21:37:05 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19133

          Issue ID: 19133
           Summary: core.exception.rangeerror at std/file.d(3812):
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Solaris
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: crayolist at 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 at 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.

--


More information about the Digitalmars-d-bugs mailing list