From f6f25011027d2949c43b0aa45270f804852a2ee1 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Mon, 12 Sep 2011 15:52:18 +0000 Subject: [PATCH] https://issues.shibboleth.net/jira/browse/SSPCPP-392 --- xmltooling/XMLObjectBuilder.cpp | 3 ++- xmltooling/base.h | 3 ++- xmltooling/util/DateTime.cpp | 10 +++++----- xmltooling/util/XMLHelper.h | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/xmltooling/XMLObjectBuilder.cpp b/xmltooling/XMLObjectBuilder.cpp index 052f80f..ec08c16 100644 --- a/xmltooling/XMLObjectBuilder.cpp +++ b/xmltooling/XMLObjectBuilder.cpp @@ -55,8 +55,9 @@ XMLObject* XMLObjectBuilder::buildFromQName(const QName& q) const XMLObject* XMLObjectBuilder::buildFromElement(DOMElement* element, bool bindDocument) const { + auto_ptr schemaType(XMLHelper::getXSIType(element)); auto_ptr 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(); diff --git a/xmltooling/base.h b/xmltooling/base.h index 0626e81..f160c72 100644 --- a/xmltooling/base.h +++ b/xmltooling/base.h @@ -1113,7 +1113,8 @@ */ #define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \ if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \ - set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \ + auto_ptr q(XMLHelper::getAttributeValueAsQName(attribute)); \ + set##proper(q.get()); \ return; \ } diff --git a/xmltooling/util/DateTime.cpp b/xmltooling/util/DateTime.cpp index 79011ff..64fe2eb 100644 --- a/xmltooling/util/DateTime.cpp +++ b/xmltooling/util/DateTime.cpp @@ -31,6 +31,7 @@ */ #include "internal.h" +#include "unicode.h" #include "util/DateTime.h" #ifndef WIN32 @@ -1315,18 +1316,17 @@ double DateTime::parseMiliSecond(const int start, const int end) const XMLString::copyNString(miliSecData, &(fBuffer[start-1]), miliSecLen); *(miliSecData + miliSecLen) = chNull; - char *nptr = XMLString::transcode(miliSecData); - ArrayJanitor jan(nptr); - size_t strLen = strlen(nptr); + auto_ptr_char nptr(miliSecData); + size_t strLen = strlen(nptr.get()); char *endptr = 0; errno = 0; //printf("milisec=<%s>\n", nptr); - double retVal = strtod(nptr, &endptr); + double retVal = strtod(nptr.get(), &endptr); // check if all chars are valid char - if ( (endptr - nptr) != strLen) + if ( (endptr - nptr.get()) != strLen) throw XMLParserException("Invalid non-numeric characters."); // we don't check underflow occurs since diff --git a/xmltooling/util/XMLHelper.h b/xmltooling/util/XMLHelper.h index 8801e8f..2fbbb3d 100644 --- a/xmltooling/util/XMLHelper.h +++ b/xmltooling/util/XMLHelper.h @@ -104,6 +104,7 @@ namespace xmltooling { /** * Gets the XSI type for a given element if it has one. + *

The caller is responsible for freeing the result. * * @param e the element * @return the type or null @@ -158,6 +159,7 @@ namespace xmltooling { /** * @deprecated * Constructs a QName from an attribute's value. + *

The caller is responsible for freeing the result. * * @param attribute the attribute with a QName value * @return a QName from an attribute's value, or null if the given attribute is null @@ -166,6 +168,7 @@ namespace xmltooling { /** * Constructs a QName from a node's value. + *

The caller is responsible for freeing the result. * * @param domNode the DOM node with a QName value * @return a QName from a node's value, or null if the given node has no value -- 2.1.4