CPPXT-104 - Add exception handling to integer conversions
[shibboleth/cpp-opensaml.git] / saml / binding / impl / ArtifactMap.cpp
index 6dd3fbb..e4bae0e 100644 (file)
@@ -106,7 +106,7 @@ void ArtifactMappings::removeMapping(const map<string,Mapping>::iterator& i)
 
 void ArtifactMappings::storeContent(XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty, int TTL)
 {
-    Lock wrapper(m_lock.get());
+    Lock wrapper(m_lock);
 
     // Garbage collect any expired artifacts.
     time_t now = time(nullptr);
@@ -128,8 +128,8 @@ void ArtifactMappings::storeContent(XMLObject* content, const SAMLArtifact* arti
 
 XMLObject* ArtifactMappings::retrieveContent(const SAMLArtifact* artifact, const char* relyingParty)
 {
-    Category& log=Category::getInstance(SAML_LOGCAT".ArtifactMap");
-    Lock wrapper(m_lock.get());
+    Category& log=Category::getInstance(SAML_LOGCAT ".ArtifactMap");
+    Lock wrapper(m_lock);
 
     map<string,Mapping>::iterator i = m_artMap.find(SAMLArtifact::toHex(artifact->getMessageHandle()));
     if (i == m_artMap.end())
@@ -190,7 +190,12 @@ ArtifactMap::ArtifactMap(const DOMElement* e, xmltooling::StorageService* storag
 
         const XMLCh* TTL = e->getAttributeNS(nullptr, artifactTTL);
         if (TTL) {
-            m_artifactTTL = XMLString::parseInt(TTL);
+            try {
+                m_artifactTTL = XMLString::parseInt(TTL);
+            }
+            catch (XMLException&) {
+                m_artifactTTL = 0;
+            }
             if (!m_artifactTTL)
                 m_artifactTTL = 180;
         }
@@ -251,7 +256,7 @@ XMLObject* ArtifactMap::retrieveContent(const SAMLArtifact* artifact, const char
 #ifdef _DEBUG
     xmltooling::NDC ndc("retrieveContent");
 #endif
-    Category& log=Category::getInstance(SAML_LOGCAT".ArtifactMap");
+    Category& log=Category::getInstance(SAML_LOGCAT ".ArtifactMap");
 
     if (!m_storage)
         return m_mappings->retrieveContent(artifact, relyingParty);