Memory leak on mundane string retrieval?

GHS
2012-02-13
2013-05-20
  • GHS
    GHS
    2012-02-13

    Hi all.  I'm testing my iPhone app for leaks with Instruments, and it's flagging the following routine as being a source of malloc leaks in conjunction with std::string.  I can't see any leaks here, since I'm doing everything by reference.  Am I missing something?  Thanks!

    std::string DeXMLator::getChildElementAsString(const TiXmlElement* pParentElement, const std::string& childName)
    {
        const TiXmlElement* pCurrElement = dynamic_cast<const TiXmlElement*>(pParentElement->FirstChild(childName.c_str()));
        if(pCurrElement)
        {
            if(pCurrElement->GetText())
            {
                return pCurrElement->GetText();
            }
        }
        return "";
    }