From 161854bfe694170b8f4f6b23f4ba20e039788ab9 Mon Sep 17 00:00:00 2001 From: weiqiaomiao Date: Sat, 23 Apr 2016 02:19:59 +0800 Subject: [PATCH] rgw: fix memory leak in func 'RGWCreateBucket_ObjStore_S3::get_params' (#8670) Signed-off-by: weiqiaomiao Reviewed-by: Casey Bodley --- src/rgw/rgw_rest_s3.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 2ef10a5ed7426..04ee28f0175b2 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -923,6 +923,8 @@ int RGWCreateBucket_ObjStore_S3::get_params() op_ret = rgw_rest_read_all_input(s, &data, &len, CREATE_BUCKET_MAX_REQ_LEN); if ((op_ret < 0) && (op_ret != -ERR_LENGTH_REQUIRED)) return op_ret; + + auto data_deleter = std::unique_ptr{data, free}; if (s->aws4_auth_needs_complete) { int ret_auth = do_aws4_auth_completion(); @@ -947,10 +949,8 @@ int RGWCreateBucket_ObjStore_S3::get_params() if (!success) { ldout(s->cct, 0) << "failed to parse input: " << data << dendl; - free(data); return -EINVAL; } - free(data); if (!parser.get_location_constraint(location_constraint)) { ldout(s->cct, 0) << "provided input did not specify location constraint correctly" << dendl; -- 2.39.5