2nd example on fpjson causes memleak
Original Reporter info from Mantis: soerensen3
-
Reporter name:
Original Reporter info from Mantis: soerensen3
- Reporter name:
Description:
the second example of the fpjson examples in the official doc causes a memleak on https://www.freepascal.org/docs-html/fcl/fpjson/index.html
If you compile with -gh you can see what I mean.
D:=GetJSON('{ "Children" : ['+
' { "Age" : 23, '+
' "Names" : { "LastName" : "Rodriquez",'+
' "FirstName" : "Roberto" }},'+
' { "Age" : 20,'+
' "Names" : { "LastName" : "Rodriquez",'+
' "FirstName" : "Maria" }}'+
' ]}');
E:=D.FindPath('Children[1].Names.FirstName');
Writeln(E.AsJSON);
FreeAndNil( D ); //<--- This line is missing!
In general I think it wouldnt hurt to say say something about the management of descendants of TJSONData in the documentation. As far as I know it it is in the responsibility of the user to free the root element but child elements get freed automatically. For example: The result of GetJSON has to be freed by the user. This will automatically free all the child nodes.
Mantis conversion info:
- Mantis ID: 32737
- OS: all os
- OS Build: all os versions
- Platform: documentation
- Version: 3.0.2
- Fixed in revision: 1492 (#260861e1)