SymbiSoft / s60-json-library

Automatically exported from code.google.com/p/s60-json-library
0 stars 0 forks source link

Potential memory leaks in JsonArray.cpp #18

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
There is a lot of code of the form

    CJsonString* string = new (ELeave) CJsonString; 
    string->SetIntL(aValue);
    iElements.AppendL( string );

If either of SetIntL or AppendL leaves, 'string' will be leaked.
The code above should be written as:

    CJsonString* string = new (ELeave) CJsonString; 
        CleanupStack::PushL(string);
    string->SetIntL(aValue);
    iElements.AppendL( string );
        CleanupStack::Pop(string); // Don't use PopAndDestroy because iElements acquires ownership of 'string'

Original issue reported on code.google.com by dirtydr...@gmail.com on 15 Sep 2010 at 8:37