Skip to content

Fix array memory leak #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/HmacSha1Signer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions core/src/ServiceRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ServiceRequest &ServiceRequest::operator=(ServiceRequest &&other) {

ServiceRequest::~ServiceRequest() {
if (content_)
delete content_;
delete[] content_;
}

const char *ServiceRequest::content() const { return content_; }
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down