CPPXT-104 - Add exception handling to integer conversions
[shibboleth/cpp-xmltooling.git] / xmltooling / util / XMLHelper.cpp
index a270de4..2682395 100644 (file)
@@ -338,9 +338,11 @@ int XMLHelper::getAttrInt(const DOMElement* e, int defValue, const XMLCh* localN
     if (e) {
         const XMLCh* val = e->getAttributeNS(ns, localName);
         if (val && *val) {
-            int i = XMLString::parseInt(val);
-            if (i)
-                return i;
+            try {
+                return XMLString::parseInt(val);
+            }
+            catch (XMLException&) {
+            }
         }
     }
     return defValue;