Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / asio / ssl / impl / rfc2818_verification.ipp
index 8d577b8..e4f28ef 100644 (file)
@@ -2,7 +2,7 @@
 // ssl/impl/rfc2818_verification.ipp
 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -70,7 +70,10 @@ bool rfc2818_verification::operator()(
         const char* pattern = reinterpret_cast<const char*>(domain->data);
         std::size_t pattern_length = domain->length;
         if (match_pattern(pattern, pattern_length, host_.c_str()))
+        {
+          GENERAL_NAMES_free(gens);
           return true;
+        }
       }
     }
     else if (gen->type == GEN_IPADD && is_address)
@@ -82,17 +85,24 @@ bool rfc2818_verification::operator()(
         {
           ip::address_v4::bytes_type bytes = address.to_v4().to_bytes();
           if (memcmp(bytes.data(), ip_address->data, 4) == 0)
+          {
+            GENERAL_NAMES_free(gens);
             return true;
+          }
         }
         else if (address.is_v6() && ip_address->length == 16)
         {
           ip::address_v6::bytes_type bytes = address.to_v6().to_bytes();
           if (memcmp(bytes.data(), ip_address->data, 16) == 0)
+          {
+            GENERAL_NAMES_free(gens);
             return true;
+          }
         }
       }
     }
   }
+  GENERAL_NAMES_free(gens);
 
   // No match in the alternate names, so try the common names. We should only
   // use the "most specific" common name, which is the last one in the list.