www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21729] New: rawRead derefences null pointer if invoked on

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 puremagic.com
          Reporter: kdevel 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

--
Mar 18 2021