Incorrect (De)allocation

  • NoodlePowa

    NoodlePowa - 2009-12-24

    When trying to load a file, `pHeader->eType == ALLOC_New and eType == ALLOC_NewArray` which is not good. :(

    Here's the call to delete in the quit() function in TinyXML:
    `delete  ( reinterpret_cast<int*>( rep_ ) );`

    And the corresponding new in init():
    `rep_ = reinterpret_cast<Rep*>( new int );`

    Now, obviously, the allocation call would call:
    `void* operator new(size_t nSize)`
    but it doesn't. Instead, it calls:
    `void* operator new(size_t nSize)`
    Even when it allocates an array, it still calls the wrong overloaded function, causing my application to leak like a French cheese. Why is this happening?

  • Lee Thomason

    Lee Thomason - 2009-12-25

    I'm not sure I follow you; this new:

        rep_ = reinterpret_cast<Rep*>( new int );

    is matched by this delete:

        delete  ( reinterpret_cast<int*>( rep_ ) );

    Which is odd but the types ( int  ) match. I don't think the leak is from TinyXML. Did you see something else, or have a code snippet you can file as a bug?


Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks