From 052d209f01865dec114865a37187a0779f2f772a Mon Sep 17 00:00:00 2001 From: ssilin Date: Thu, 8 Feb 2024 02:33:37 +0300 Subject: [PATCH] fix-client-memory-dealloc fix review --- src/client.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client.cc b/src/client.cc index e72f6af3..e476195b 100644 --- a/src/client.cc +++ b/src/client.cc @@ -683,10 +683,16 @@ minio::s3::PutObjectResponse minio::s3::Client::PutObject(PutObjectArgs args) { "SSE operation must be performed over a secure connection"); } - std::vector buf(args.part_size + 1); + char* buf = NULL; + if (args.part_count > 0) { + buf = new char[args.part_size]; + } else { + buf = new char[args.part_size + 1]; + } std::string upload_id; - PutObjectResponse resp = PutObject(args, upload_id, (char*)&buf[0]); + PutObjectResponse resp = PutObject(args, upload_id, buf); + delete[] buf; if (!resp && !upload_id.empty()) { AbortMultipartUploadArgs amu_args;