A little error

Dave84311
2012-10-01
2013-06-12
  • Dave84311

    Dave84311 - 2012-10-01

    I'd suggest changing your deleteInternal function to this:

    void internalJSONNode::deleteInternal(internalJSONNode * ptr) json_nothrow {
    #ifdef JSON_MEMORY_POOL /*-> JSON_MEMORY_POOL */
    ptr -> ~internalJSONNode();
    json_internal_mempool.deallocate((void*)ptr);
    #elif defined(JSON_MEMORY_CALLBACKS) /*<- else JSON_MEMORY_CALLBACKS */
    ptr -> ~internalJSONNode();
    libjson_free<internalJSONNode>(ptr);
    #else /*<- else */
    if (ptr != NULL)
    delete ptr;
    #endif /*<- */
    }

    More specifically:

    if (ptr != NULL)
    delete ptr;

    It appears that this function tries to delete an invalid pointer, and causes one of my programs to crash.

    The following code in a separate thread seems to be causing the issue.
    JSONNode v(JSON_NODE);
    v.set_name("abc");
    v.push_back(JSONNode("123l", test.c_str())); <- Issue occurs when this isn't commented out.

     
  • Dave84311

    Dave84311 - 2012-10-01

    I forgot to add the issue is with a visual studios compiled application in debug mode and while the app isn't being debugged in visual studios (stand alone).

    I'm not too sure why the pointer is being invalidated, but it is good practice to check if it is valid anyways.

     
  • Jonathan Wallace

    Interesting, I will look into it, I use similar code all the time.  Could you give me your JSONOptions.h file?

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks