Skip to content

Fix memory leak in createPDFDataWithBitmapImage #13

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
Oct 24, 2023
Merged

Fix memory leak in createPDFDataWithBitmapImage #13

merged 1 commit into from
Oct 24, 2023

Conversation

AndreiArdelean1
Copy link
Contributor

Fixes #12

@dreampiggy
Copy link
Collaborator

Opppps...Seems this leak exists long times ago.

I'll run Xcode analayze and memory leak detection after merging your PR as well.

@dreampiggy dreampiggy merged commit 42e5637 into SDWebImage:master Oct 24, 2023
@dreampiggy
Copy link
Collaborator

dreampiggy commented Oct 24, 2023

Seems there are more issues after changes

image

@dreampiggy
Copy link
Collaborator

dreampiggy commented Oct 24, 2023

The correct fix should be:

{
    ...   
    NSData *result = [pdfData copy];
    
    CGDataConsumerRelease(pdfConsumer);
    CGContextRelease(context);

    return result;
}

The CGImageRef is GET rule (because it's get from UIImage's own buffer), so do not call Release on it.

@dreampiggy
Copy link
Collaborator

Released v1.0.1

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.

Memory leak in +[SDImagePDFCoder createPDFDataWithBitmapImage:]
2 participants