Fix array memory leak

This commit is contained in:
weeping
2025-03-17 17:14:13 +08:00
committed by page
parent 1954195d9c
commit ec9cd15b58
3 changed files with 4 additions and 4 deletions

View File

@@ -79,7 +79,7 @@ std::string HmacSha1Signer::generate(const std::string &src,
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
std::string ret = std::string(dest, dlen);
delete dest;
delete[] dest;
return ret;
#else
unsigned char md[EVP_MAX_BLOCK_LENGTH];

View File

@@ -62,7 +62,7 @@ ServiceRequest &ServiceRequest::operator=(ServiceRequest &&other) {
ServiceRequest::~ServiceRequest() {
if (content_)
delete content_;
delete[] 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) {
if (content_)
delete content_;
delete[] content_;
content_ = nullptr;
contentSize_ = 0;
if (size) {

View File

@@ -89,7 +89,7 @@ std::string AlibabaCloud::ComputeContentMD5(const char *data, size_t size) {
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
std::string ret = std::string(dest, dlen);
delete dest;
delete[] dest;
return ret;
#else
unsigned char md[MD5_DIGEST_LENGTH];