Fix array memory leak
This commit is contained in:
@@ -79,7 +79,7 @@ std::string HmacSha1Signer::generate(const std::string &src,
|
|||||||
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
||||||
|
|
||||||
std::string ret = std::string(dest, dlen);
|
std::string ret = std::string(dest, dlen);
|
||||||
delete dest;
|
delete[] dest;
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
unsigned char md[EVP_MAX_BLOCK_LENGTH];
|
unsigned char md[EVP_MAX_BLOCK_LENGTH];
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ ServiceRequest &ServiceRequest::operator=(ServiceRequest &&other) {
|
|||||||
|
|
||||||
ServiceRequest::~ServiceRequest() {
|
ServiceRequest::~ServiceRequest() {
|
||||||
if (content_)
|
if (content_)
|
||||||
delete content_;
|
delete[] content_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ServiceRequest::content() const { return content_; }
|
const char *ServiceRequest::content() const { return content_; }
|
||||||
@@ -73,7 +73,7 @@ bool ServiceRequest::hasContent() const { return (contentSize_ != 0); }
|
|||||||
|
|
||||||
void ServiceRequest::setContent(const char *data, size_t size) {
|
void ServiceRequest::setContent(const char *data, size_t size) {
|
||||||
if (content_)
|
if (content_)
|
||||||
delete content_;
|
delete[] content_;
|
||||||
content_ = nullptr;
|
content_ = nullptr;
|
||||||
contentSize_ = 0;
|
contentSize_ = 0;
|
||||||
if (size) {
|
if (size) {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ std::string AlibabaCloud::ComputeContentMD5(const char *data, size_t size) {
|
|||||||
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
||||||
|
|
||||||
std::string ret = std::string(dest, dlen);
|
std::string ret = std::string(dest, dlen);
|
||||||
delete dest;
|
delete[] dest;
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
unsigned char md[MD5_DIGEST_LENGTH];
|
unsigned char md[MD5_DIGEST_LENGTH];
|
||||||
|
|||||||
Reference in New Issue
Block a user