-
-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.File.flush and error causes segfault after calling close #1997
Conversation
{ | ||
import std.exception : enforce, errnoEnforce; | ||
|
||
enforce(isOpen, "Attempting to flush() in an unopened file"); | ||
errnoEnforce | ||
(.fflush(enforce(_p.handle, "Calling fflush() on an unopened file")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, is this second enforce now unnecessary since you added the new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's safe to say that isOpen
=> _p.handle !is null
, so the second enforce can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comments.
I removed the second enforce.
Please add a test-case. Thanks. |
I added unittests for Issue 12349. |
Auto-merge toggled on |
std.File.flush and error causes segfault after calling close
Thanks! |
Thank you. |
Bugzilla: https://d.puremagic.com/issues/show_bug.cgi?id=12349
I also mark them as
@trusted
.