digitalmars.D.bugs - [Issue 24165] New: Failed readf leaves File in inconsistent state
- d-bugmail puremagic.com (32/32) Sep 26 2023 https://issues.dlang.org/show_bug.cgi?id=24165
https://issues.dlang.org/show_bug.cgi?id=24165 Issue ID: 24165 Summary: Failed readf leaves File in inconsistent state Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com Example: --- $ echo "-hello" > input $ cat example.d import std.stdio, std.format, std.algorithm; void main() { auto f = File("input"); int n; try f.readf("%d", n); catch (Exception e) {} f.byChunk(1).copy(stdout.lockingBinaryWriter); } $ dmd -run example.d hhello --- After the failed call to File.readf, subsequent reads from `f` result in corrupted data. --
Sep 26 2023