Correct use of auto_ptr.
authorScott Cantor <cantor.2@osu.edu>
Mon, 6 Aug 2007 03:55:13 +0000 (03:55 +0000)
committerScott Cantor <cantor.2@osu.edu>
Mon, 6 Aug 2007 03:55:13 +0000 (03:55 +0000)
shibsp/attribute/NameIDAttributeDecoder.cpp

index e813bc1..4ed2cda 100644 (file)
@@ -167,11 +167,11 @@ void NameIDAttributeDecoder::extract(
     const NameIDType* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty\r
     ) const\r
 {\r
-    char* name = toUTF8(n->getName());\r
-    if (name && *name) {\r
+    auto_arrayptr<char> name(toUTF8(n->getName()));\r
+    if (name.get() && *name.get()) {\r
         dest.push_back(NameIDAttribute::Value());\r
         NameIDAttribute::Value& val = dest.back();\r
-        val.m_Name = name;\r
+        val.m_Name = name.get();\r
         char* str = toUTF8(n->getFormat());\r
         if (str) {\r
             val.m_Format = str;\r
@@ -198,18 +198,17 @@ void NameIDAttributeDecoder::extract(
             delete[] str;\r
         }\r
     }\r
-    delete[] name;\r
 }\r
 \r
 void NameIDAttributeDecoder::extract(\r
     const NameIdentifier* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty\r
     ) const\r
 {\r
-    char* name = toUTF8(n->getName());\r
-    if (name && *name) {\r
+    auto_arrayptr<char> name(toUTF8(n->getName()));\r
+    if (name.get() && *name.get()) {\r
         dest.push_back(NameIDAttribute::Value());\r
         NameIDAttribute::Value& val = dest.back();\r
-        val.m_Name = name;\r
+        val.m_Name = name.get();\r
         char* str = toUTF8(n->getFormat());\r
         if (str) {\r
             val.m_Format = str;\r
@@ -226,5 +225,4 @@ void NameIDAttributeDecoder::extract(
         if (relyingParty)\r
             val.m_SPNameQualifier = relyingParty;\r
     }\r
-    delete[] name;\r
 }\r