json_string vs json_char *

  • ganesh

    ganesh - 2012-11-08

    Hi, I have the following boost unit test:
         JSONNode node;
         json_string sResult = json_write_formatted(&node);    
    Memory leak is detected if I use the above unit test.
    1>  Detected memory leaks!
    1>  Dumping objects ->
    1>  {794} normal block at 0x00772420, 12 bytes long.
    1>   Data: <{ }         > 7B 00 7D 00 00 00 CD CD CD CD CD CD

    But if I use json_char*, there is no memory leak:
         JSONNode node;
          json_char *jc =  json_write_formatted(&node);

    How to use json_string without memory leak ?

    Thanks !

  • Jonathan Wallace

    That is up to your string libraries implementation.  json_string is defined as std::string in almost all cases, you are getting a false positive.  It's possible that a global is being initialized too, which also causes false positives.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks