-
Notifications
You must be signed in to change notification settings - Fork 10.5k
libSyntax: ensure copy constructor of OwnedString to release previously allocated data. rdar://35116413 #12610
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
…ly allocated data. rdar://35116413 Issue detected by the awesome leak sanitizer bot.
@swift-ci please smoke test |
include/swift/Basic/OwnedString.h
Outdated
@@ -44,10 +44,15 @@ class OwnedString { | |||
size_t Length; | |||
StringOwnership Ownership; | |||
|
|||
void release() { | |||
if (Ownership == StringOwnership::Copied) | |||
free(const_cast<char *>(Data)); |
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.
Quick drive by: Why are we freeing this. Why are we not using delete []?
On another note, I am just happy we are catching these leaks.
@swift-ci please smoke test |
@swift-ci please test |
Build failed |
Build failed |
include/swift/Basic/OwnedString.h
Outdated
|
||
OwnedString(const OwnedString &Other) { | ||
// Release previously allocated data. | ||
release(); |
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.
This can't happen. Are you sure it didn't mean the copy assignment operator?
(Also, you should probably add move operators as well. Rule of Five!)
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.
Oh, you’re right. This meant to be the copy assignment operator. Will fix
@jrose-apple could you please take another look? |
@swift-ci please smoke test |
Issue detected by the awesome leak sanitizer bot.
cc @gottesmm