-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Foundation: FileHandle.swift: memory leak in _readDataOfLength #1155
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
Conversation
@@ -109,7 +109,7 @@ open class FileHandle : NSObject, NSSecureCoding { | |||
|
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.
For clarity, can we change this:
if (0 == total) { } if (total > 0) { }
to an if-else?
Just so we make sure we can't exit this function without either a free or data creation with .free
.
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.
The earlier code paths ensure that the total will never be negative. Regardless, I updated this to cover all cases and added an assertion in the unreachable case.
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.
@parkera Please review the updated commit.
`dynamicBuffer` will never be freed if `total > 0`. Fix this by giving the underlying Data a "free" destructor. This is covered by existing tests.
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
@ianpartridge @alblue Hmm, seems like there were some server errors: |
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
dynamicBuffer
will never be freed iftotal > 0
. Fix this by giving the underlying Data a "free" destructor. This is covered by existing tests.