Skip to content

[SR-3481] Fix for memory leak in NSURLComponents #897

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

Merged
merged 1 commit into from
Feb 28, 2017
Merged

[SR-3481] Fix for memory leak in NSURLComponents #897

merged 1 commit into from
Feb 28, 2017

Conversation

nethraravindran
Copy link
Contributor

No description provided.

private let _components : CFURLComponentsRef!

deinit {
if let component = _components {
__CFURLComponentsDeallocate(component)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Called CoreFoundation deallocate method to free the resources.

static void __CFURLComponentsDeallocate(CFTypeRef cf) {
CFURLComponentsRef instance = (CFURLComponentsRef)cf;
__CFGenericValidateType(cf, _CFURLComponentsGetTypeID());
CF_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef instance) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used CF_EXPORT in-order to call from deinit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleaes make this CF_SWIFT_EXPORT

@nethraravindran nethraravindran changed the title Fix for memory leak in NSURLComponents Fix for memory leak in NSURLComponents [SR-3481] Feb 27, 2017
@nethraravindran nethraravindran changed the title Fix for memory leak in NSURLComponents [SR-3481] [SR-3481] Fix for memory leak in NSURLComponents Feb 27, 2017
@@ -948,8 +948,15 @@ open class NSURLQueryItem : NSObject, NSSecureCoding, NSCopying {
}

open class NSURLComponents: NSObject, NSCopying {
private let _cfinfo = _CFInfo(typeID: _CFURLComponentsGetTypeID())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realised it is no longer required. Will remove.

Copy link
Contributor

@parkera parkera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with a couple small changes. Thanks!

static void __CFURLComponentsDeallocate(CFTypeRef cf) {
CFURLComponentsRef instance = (CFURLComponentsRef)cf;
__CFGenericValidateType(cf, _CFURLComponentsGetTypeID());
CF_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef instance) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleaes make this CF_SWIFT_EXPORT

@@ -30,6 +30,8 @@ typedef struct __CFURLComponents *CFURLComponentsRef;

CF_EXPORT CFTypeID _CFURLComponentsGetTypeID(void);

CF_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CF_SWIFT_EXPORT here too.

@nethraravindran
Copy link
Contributor Author

@parkera Addressed the changes.

@parkera
Copy link
Contributor

parkera commented Feb 28, 2017

@swift-ci please test and merge

@swift-ci swift-ci merged commit 3719f59 into swiftlang:master Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants