]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix memory leak in func 'RGWCreateBucket_ObjStore_S3::get_params' (#8670)
authorweiqiaomiao <wei.qiaomiao@zte.com.cn>
Fri, 22 Apr 2016 18:19:59 +0000 (02:19 +0800)
committerCasey Bodley <cbodley@users.noreply.github.com>
Fri, 22 Apr 2016 18:19:59 +0000 (14:19 -0400)
Signed-off-by: weiqiaomiao <wei.qiaomiao@zte.com.cn>
Reviewed-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rest_s3.cc

index 2ef10a5ed7426611b1a440dedb98be4108b54361..04ee28f0175b2d7e14cb1ed5337a3a168290fa2e 100644 (file)
@@ -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<char, decltype(free)*>{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;