Memory leak in er_compute_xpath

John Cruz
  • John Cruz

    John Cruz - 2009-06-09

    I haven't gone deeper in my debugging but I can definitely say that there is a memory leak being created when calling TinyXPath::xpath_processor::er_compute_xpath() from within S_compute_xpath().

    I'm not sure if I am just invoking it wrong but here is an overview of how I use TinyXPath...

    // CODE: START
    std::string xmlstr;
    // xmlstr = some valid XML string

    std::string xpathstr;
    // xpathstr = some valid xpath string

    TiXmlDocument doc;
    doc.Parse( xmlstr.str());

    if( doc.Error()) return "";

    TinyXPath::xpath_processor x( doc.RootElement(), xpathstr );
    std::string ret=x.S_compute_xpath().c_str();

    return ret;
    // CODE: END

    Is there any free/delete function I should be calling?

    Thanks in advance!


    • John Cruz

      John Cruz - 2009-06-09


      TinyXPath::xpath_processor x( doc.RootElement(), xpathstr );

      should read as

      TinyXPath::xpath_processor x( doc.RootElement(), xpathstr.c_str());

  • Benjamin Rood

    Benjamin Rood - 2012-09-13

    Since you constructed the object on the stack, it will be deleted when the function returns.  Hopefully, there are no undiscovered memory leaks in TinyXPath because the destructor didn't clean up after itself properly.


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