Skip to content
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

Merged
3 commits merged into from
Mar 12, 2014
Merged

std.File.flush and error causes segfault after calling close #1997

3 commits merged into from
Mar 12, 2014

Conversation

tom-tan
Copy link
Contributor

@tom-tan tom-tan commented Mar 12, 2014

Bugzilla: https://d.puremagic.com/issues/show_bug.cgi?id=12349

I also mark them as @trusted.

{
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"))
Copy link

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@ghost
Copy link

ghost commented Mar 12, 2014

Please add a test-case. Thanks.

@tom-tan
Copy link
Contributor Author

tom-tan commented Mar 12, 2014

I added unittests for Issue 12349.

@ghost
Copy link

ghost commented Mar 12, 2014

Auto-merge toggled on

ghost pushed a commit that referenced this pull request Mar 12, 2014
std.File.flush and error causes segfault after calling close
@ghost ghost merged commit cb26b36 into dlang:master Mar 12, 2014
@tom-tan tom-tan deleted the trusted-std-stdio-File-error-flush branch March 12, 2014 16:40
@tom-tan
Copy link
Contributor Author

tom-tan commented Mar 12, 2014

Thanks!

@ghost
Copy link

ghost commented Mar 12, 2014

Thank you.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants