[JIRA] Closed: (CPPXT-86) Small Memory Leak in XMLObjectBuilder::buildFromElement()

Scott Cantor (JIRA) noreply at shibboleth.net
Wed May 16 15:35:03 BST 2012


     [ https://issues.shibboleth.net/jira/browse/CPPXT-86?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Scott Cantor closed CPPXT-86.
-----------------------------


> Small Memory Leak in XMLObjectBuilder::buildFromElement()
> ---------------------------------------------------------
>
>                 Key: CPPXT-86
>                 URL: https://issues.shibboleth.net/jira/browse/CPPXT-86
>             Project: XMLTooling - C++
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 1.4.2
>            Reporter: selhorst at idp.protectnetwork.org
>            Assignee: Scott Cantor
>             Fix For: 1.5
>
>         Attachments: xmltooling_1.4.2_memory_leak.diff
>
>
> Dear XML-Tooling-Developers,
> we identified a minor memory leak in the method XMLObjectBuilder::buildFromElement() in XMLTooling (C++ Version 1.4.2).
> Please find attached a patch for this issue and the output of Valgrind before and after applying the patch.
> -----------------
> - before patch  -
> -----------------
> ==18035== Memcheck, a memory error detector
> ==18035== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
> ==18035== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
> ==18035== Command: /var/www/fcgi-bin/foo.bin
> ==18035== Parent PID: 18032
> ==18035== 
> ==18035== 1,854 (240 direct, 1,614 indirect) bytes in 10 blocks are definitely lost
> ==18035==    at 0x4C24DFA: operator new(unsigned long) (vg_replace_malloc.c:261)
> ==18035==    by 0x7259F84: xmltooling::XMLHelper::getXSIType(xercesc_3_1::DOMElement const*) (XMLHelper.cpp:59)
> ==18035==    by 0x722AA69: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:60)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x5CE5489: opensaml::saml2::EncryptedElementType::decrypt(xmltooling::CredentialResolver const&, unsigned short const*, xmltooling::CredentialCriteria*) const (Assertions.cpp:269)
> ==18035==    by 0x439303: main (foo.cxx:509)
> ==18035== 2,670 (312 direct, 2,358 indirect) bytes in 13 blocks are definitely lost
> ==18035==    at 0x4C24DFA: operator new(unsigned long) (vg_replace_malloc.c:261)
> ==18035==    by 0x7259F84: xmltooling::XMLHelper::getXSIType(xercesc_3_1::DOMElement const*) (XMLHelper.cpp:59)
> ==18035==    by 0x722AA69: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:60)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x723887F: xmltooling::AbstractXMLObjectUnmarshaller::unmarshallContent(xercesc_3_1::DOMElement const*) (AbstractXMLObjectUnmarshaller.cpp:199)
> ==18035==    by 0x7239A29: xmltooling::AbstractXMLObjectUnmarshaller::unmarshall(xercesc_3_1::DOMElement*, bool) (AbstractXMLObjectUnmarshaller.cpp:73)
> ==18035==    by 0x722AAC8: xmltooling::XMLObjectBuilder::buildFromElement(xercesc_3_1::DOMElement*, bool) const (XMLObjectBuilder.cpp:61)
> ==18035==    by 0x5CE5489: opensaml::saml2::EncryptedElementType::decrypt(xmltooling::CredentialResolver const&, unsigned short const*, xmltooling::CredentialCriteria*) const (Assertions.cpp:269)
> ==18035==    by 0x439303: main (foo.cxx:509)
> ==18035== 
> ==18035== LEAK SUMMARY:
> ==18035==    definitely lost: 552 bytes in 23 blocks
> ==18035==    indirectly lost: 3,972 bytes in 69 blocks
> ==18035==         suppressed: 0 bytes in 0 blocks
> -----------------
> -  after patch  -
> -----------------
> ==18838== Memcheck, a memory error detector
> ==18838== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
> ==18838== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
> ==18038== Command: /var/www/fcgi-bin/foo.bin
> ==18838== Parent PID: 18835
> ==18838== 
> ==18838== LEAK SUMMARY:
> ==18838==    definitely lost: 0 bytes in 0 blocks
> ==18838==    indirectly lost: 0 bytes in 0 blocks
> ==18838==         suppressed: 0 bytes in 0 blocks
> -----------------
> -     patch     -
> -----------------
> --- XMLObjectBuilder.cpp.orig	2012-04-10 15:41:49.000000000 +0200
> +++ XMLObjectBuilder.cpp	2012-04-10 15:43:01.000000000 +0200
> @@ -55,9 +55,9 @@ XMLObject* XMLObjectBuilder::buildFromQN
>  
>  XMLObject* XMLObjectBuilder::buildFromElement(DOMElement* element, bool bindDocument) const
>  {
> +    auto_ptr<QName> schemaType(XMLHelper::getXSIType(element));
>      auto_ptr<XMLObject> ret(
> -        buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),XMLHelper::getXSIType(element))
> -        );
> +        buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),schemaType.get()));
>      ret->unmarshall(element,bindDocument);
>      return ret.release();
>  }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the commits mailing list