I think I've found a couple bugs in getXSDType, one of which is causing a crash. I believe this was revealed by the recent change made to getElement() to check if the type is known/unknown. getXSDType is crashing when it tries to parse the 'nil="true"' attribute in an element. after calling qn.splitQNameString() it doesn't check qn.uri fro NULL, which it is in this case.

Previously getElement had some code that looked like this:

        if (0 == strcmp (pName, m_pNode->m_pchNameOrValue))
            bNillFound = isNillValue();
if (bNillFound || isArrayElement || (pSimpleType->getType() == getXSDType(m_pNode))

but now looks like this:

        if (0 == strcmp (pName, m_pNode->m_pchNameOrValue))
            bNillFound = isNillValue();
        bool foundType;
        XSDTYPE theType = getXSDType(m_pNode, foundType);
if (bNillFound || isArrayElement || (pSimpleType->getType() == theType) || !foundType)

so what's happening is before we would skip the call to getXSDType() if the element was nil, but now we call getXSDType() every time. I made the attached change and it fixes the crash.

However, I am a little unsure that this code is going to work reliably to detect the type (with or without my change). it looks to me like it will treat the very first attribute it finds as the type--and even then it will fail if the attribute doesn't have a namespace prefix.




Index: src/soap/SoapDeSerializer.cpp
===================================================================
--- src/soap/SoapDeSerializer.cpp       (revision 498771)
+++ src/soap/SoapDeSerializer.cpp       (working copy)
@@ -1870,7 +1870,7 @@
 XSDTYPE SoapDeSerializer::
 getXSDType (const AnyElement * pElement, bool & foundType)
 {
-    foundType = true;
+    foundType = false;
     
     /* first check whether this is a start element node */
     if (START_ELEMENT != pElement->m_type)
@@ -1883,18 +1883,21 @@
             ::QName qn;
             XSDTYPE type = XSD_UNKNOWN;
             qn.splitQNameString (pElement->m_pchAttributes[i + 2], ':');
-            const char * pNS = m_pParser->getNS4Prefix (qn.uri);
-            if (pNS)
+            if (qn.uri)
             {
-                if (URI_XSD == URIMapping::getURI (pNS) || URI_ENC == 
URIMapping::getURI (pNS))
-                    type = TypeMapping::map (qn.localname);
+                const char * pNS = m_pParser->getNS4Prefix (qn.uri);
+                if (pNS)
+                {
+                    if (URI_XSD == URIMapping::getURI (pNS) || URI_ENC == 
URIMapping::getURI (pNS))
+                        type = TypeMapping::map (qn.localname);
+                }
+                qn.mergeQNameString (':');
+                foundType = true;
+                return type;
             }
-            qn.mergeQNameString (':');
-            return type;
         }
     }
 
-    foundType = false;
     return XSD_UNKNOWN;
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to