vendredi 29 juillet 2016

C++ code with poco json crashes after method ends

I have this very simple C++ method that uses poco json for querying a json string. Apparently it crashes after the method ends. The details of the crash are after my source code

void SomeClass::processJson(std::shared_ptr<Foo> code,std::string& json)
{
    try
    {
        std::string json_str = json;
        Parser parser;
        Var result;

        ParseHandler handler;
        parser.setHandler(&handler);
        parser.parse(json_str);
        result = handler.asVar();

        Query query(result);
        Poco::JSON::Array::Ptr arr= query.findArray("result.payload.infos");

        int t = arr->size();

    } catch (...)
    {

    }
}

Now as soon as the method ends i get a crash indicating this code in the stack trace in Var.h of POCO

#ifdef POCO_NO_SOO

    VarHolder* content() const
    {
        return _pHolder;
    }

    void destruct()
    {
        if (!isEmpty()) delete content();
    }

    VarHolder* _pHolder;

#else

A copy of the stack trace after this method is below

enter image description here

Aucun commentaire:

Enregistrer un commentaire