From: bert hubert Date: Tue, 3 Feb 2015 22:04:46 +0000 (+0100) Subject: scoped_array/scoped_ptr mistake, found by rubenk's address sanitizer check run X-Git-Tag: rec-3.7.0-rc2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5fdd91dbc479d311a2afbd9021178065153c75d0;p=pdns scoped_array/scoped_ptr mistake, found by rubenk's address sanitizer check run --- diff --git a/pdns/base64.cc b/pdns/base64.cc index 5c04d01cb..87bebd857 100644 --- a/pdns/base64.cc +++ b/pdns/base64.cc @@ -1,5 +1,5 @@ #include "base64.hh" -#include +#include #include int B64Decode(const std::string& src, std::string& dst) @@ -9,7 +9,7 @@ int B64Decode(const std::string& src, std::string& dst) return 0; } size_t dlen = ( src.length() * 6 + 7 ) / 8 ; - boost::scoped_ptr d( new unsigned char[dlen] ); + boost::scoped_array d( new unsigned char[dlen] ); if ( base64_decode( d.get(), &dlen, (const unsigned char*) src.c_str(), src.length() ) == 0 ) { dst = std::string( (const char*) d.get(), dlen ); return 0; @@ -21,7 +21,7 @@ std::string Base64Encode (const std::string& src) { if (!src.empty()) { size_t dlen = ( ( ( src.length() + 2 ) / 3 ) * 4 ) + 1; - boost::scoped_ptr dst( new unsigned char[dlen] ); + boost::scoped_array dst( new unsigned char[dlen] ); if( base64_encode( dst.get(), &dlen, (const unsigned char*) src.c_str(), src.length() ) == 0 ) return std::string( (const char*) dst.get(), dlen ); }