Skip to content

Commit ec9cd15

Browse files
TsinghuaDreampeze
authored andcommitted
Fix array memory leak
1 parent 1954195 commit ec9cd15

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

core/src/HmacSha1Signer.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ std::string HmacSha1Signer::generate(const std::string &src,
7979
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
8080

8181
std::string ret = std::string(dest, dlen);
82-
delete dest;
82+
delete[] dest;
8383
return ret;
8484
#else
8585
unsigned char md[EVP_MAX_BLOCK_LENGTH];

core/src/ServiceRequest.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ServiceRequest &ServiceRequest::operator=(ServiceRequest &&other) {
6262

6363
ServiceRequest::~ServiceRequest() {
6464
if (content_)
65-
delete content_;
65+
delete[] content_;
6666
}
6767

6868
const char *ServiceRequest::content() const { return content_; }
@@ -73,7 +73,7 @@ bool ServiceRequest::hasContent() const { return (contentSize_ != 0); }
7373

7474
void ServiceRequest::setContent(const char *data, size_t size) {
7575
if (content_)
76-
delete content_;
76+
delete[] content_;
7777
content_ = nullptr;
7878
contentSize_ = 0;
7979
if (size) {

core/src/Utils.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ std::string AlibabaCloud::ComputeContentMD5(const char *data, size_t size) {
8989
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
9090

9191
std::string ret = std::string(dest, dlen);
92-
delete dest;
92+
delete[] dest;
9393
return ret;
9494
#else
9595
unsigned char md[MD5_DIGEST_LENGTH];

0 commit comments

Comments
 (0)