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

json_Merge(Objects) memleak #67

Open
Helaas opened this issue Apr 5, 2022 · 3 comments
Open

json_Merge(Objects) memleak #67

Helaas opened this issue Apr 5, 2022 · 3 comments

Comments

@Helaas
Copy link

Helaas commented Apr 5, 2022

Hello,

I've been playing around with json_Merge(Objects).
I've noticed that json_Merge & json_MergeObjects cause json_MemLeak to return true.
json_NodeClone does not have this behavior.

json_MergeObjects

pFrom = json_parseString ('{ -
     "s" : "Life is a gift",   -
     "a" : [1,2,3,4],          -
     "o" : {                   -
        "x"  : 100,            -
        "y"  : 200             -
     }                         -
  }');

// "to" is just an empty object at begining
pTo = json_newObject();

// copy all elements: This is deep copy
json_MergeObjects(pTo:pFrom:json_REPLACE);

Content = json_AsJsonText(pFrom);
Content2 = json_AsJsonText(pTo);

json_delete(pTo);
json_delete(pFrom);
*inlr = *on;

Memleak = json_MemLeak();    //Will return 1!    

json_Merge

pFrom = json_parseString ('{ -
     "s" : "Life is a gift",   -
     "a" : [1,2,3,4],          -
     "o" : {                   -
        "x"  : 100,            -
        "y"  : 200             -
     }                         -
  }');

// "to" is just an empty object at begining
pTo = json_newObject();

// copy all elements: This is deep copy
json_Merge(pTo:pFrom:json_DONTREPLACE);

Content = json_AsJsonText(pFrom);
Content2 = json_AsJsonText(pTo);

json_delete(pTo);
json_delete(pFrom);
*inlr = *on;

Memleak = json_MemLeak();    //Will return 1!    

json_NodeClone

pFrom = json_parseString ('{ -
     "s" : "Life is a gift",   -
     "a" : [1,2,3,4],          -
     "o" : {                   -
        "x"  : 100,            -
        "y"  : 200             -
     }                         -
  }');

// copy all elements: This is deep copy
pTo =  json_NodeClone(pFrom)

Content = json_AsJsonText(pFrom);
Content2 = json_AsJsonText(pTo);

json_delete(pTo);
json_delete(pFrom);
*inlr = *on;

Memleak = json_MemLeak();    //Will return 0!    
@NielsLiisberg
Copy link
Collaborator

NielsLiisberg commented Apr 12, 2022 via email

@worksofliam
Copy link
Collaborator

@NielsLiisberg What's the status here?

@NielsLiisberg
Copy link
Collaborator

Unfortunately we have not had time to fix it yet - It is on the TODO list - it is not forgotten.

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

No branches or pull requests

3 participants