Kaynağa Gözat

Fix array memory leak

weeping 1 yıl önce
ebeveyn
işleme
ec9cd15b58
3 değiştirilmiş dosya ile 4 ekleme ve 4 silme
  1. 1 1
      core/src/HmacSha1Signer.cc
  2. 2 2
      core/src/ServiceRequest.cc
  3. 1 1
      core/src/Utils.cc

+ 1 - 1
core/src/HmacSha1Signer.cc

@@ -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];

+ 2 - 2
core/src/ServiceRequest.cc

@@ -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) {

+ 1 - 1
core/src/Utils.cc

@@ -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];