[Issue 21729] New: rawRead derefences null pointer if invoked on closed File (segfault)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 18 11:14:17 UTC 2021


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

          Issue ID: 21729
           Summary: rawRead derefences null pointer if invoked on closed
                    File (segfault)
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: kdevel at vogtner.de

```n.d
import std.stdio;

void main ()
{
   File f;
   ubyte [1] u;
   auto n = f.rawRead (u);
}
```

$ dmd -g n.d
$ gdb ./n
[...]
(gdb) r
[...]
Program received signal SIGSEGV, Segmentation fault.
0xXXXXXXXXXXXXXXXX in std.stdio.File() (this=..., buffer=...)
    at [...]/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1036
1036            immutable freadResult = trustedFread(_p.handle, buffer);
(gdb) p _p
$1 = (struct std.stdio.File.Impl *) 0x0

--


More information about the Digitalmars-d-bugs mailing list