Skip to content

Fix memory leak in function CFTimeZoneCreateWithName #2816

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
Aug 20, 2020

Conversation

valeriyvan
Copy link
Contributor

No description provided.

@@ -1594,6 +1594,7 @@ CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef nam
#endif
CFRelease(dict);
if (CFEqual(CFSTR(""), name)) {
CFRelease(baseURL);
return NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a CFRelease(data); also needed for the assignment on L1574?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

data is released on L1617.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant if the return NULL on L1598 is reached then data wont have been released?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right - there's codepath where data is allocated.
And also there's code path where baseURL isn't allocated.
So I fixed both.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good, catch. Could you revert the indentation commit since we want to avoid changing unrelated lines and then squash this all down to one commit, thanks. I think it should be ok then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@spevans
Copy link
Contributor

spevans commented Jun 18, 2020

@swift-ci please test

@spevans
Copy link
Contributor

spevans commented Jun 22, 2020

@swift-ci test

@spevans
Copy link
Contributor

spevans commented Jun 22, 2020

@swift-ci please test

@valeriyvan
Copy link
Contributor Author

ping

1 similar comment
@valeriyvan
Copy link
Contributor Author

ping

@millenomi millenomi merged commit 7dbc009 into swiftlang:master Aug 20, 2020
@valeriyvan valeriyvan deleted the CFTimeZoneLeak branch August 21, 2020 17:55
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.

3 participants