Skip to content
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

Memory leak in cJSON_ReplaceItemInObject #55

Closed
dismirlian opened this issue Nov 10, 2016 · 3 comments
Closed

Memory leak in cJSON_ReplaceItemInObject #55

dismirlian opened this issue Nov 10, 2016 · 3 comments
Labels

Comments

@dismirlian
Copy link

dismirlian commented Nov 10, 2016

Hi, I think I found a memory leak in cJSON_ReplaceItemInObject:

    ....
    
    if(c)
    {
        //THESE LINES SHOULD PREVENT THE LEAK
        if (!(newitem->type & cJSON_StringIsConst) && newitem->string)
        {
           cJSON_free(newitem->string);
        }

        newitem->string = cJSON_strdup(string);
        cJSON_ReplaceItemInArray(object, i, newitem); 

Thanks,
Diego.

@FSMaxB FSMaxB added the bug label Nov 11, 2016
@FSMaxB
Copy link
Collaborator

FSMaxB commented Nov 11, 2016

Yes, that is a memory leak! Good catch, thanks for reporting this.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Nov 11, 2016

Actually there's more, I just found another one. or not.

@FSMaxB FSMaxB closed this as completed in 0d10e27 Nov 11, 2016
@dismirlian
Copy link
Author

I've just started using the library for a project. If I find another one, I'll report it.

Thanks!

Diego.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants