]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: fix leaks with make_unique() 39211/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 1 Feb 2021 21:30:05 +0000 (16:30 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 1 Feb 2021 21:44:59 +0000 (16:44 -0500)
`make_unique<T>(args...)` itself uses `new T(args...)`, so this code was
allocating an extra Formatter pointer, and passing that to the actual
Formatter's constructor where it was converted to `bool pretty` and so
never freed. this also prevented `bool pretty_format` from taking effect

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_admin.cc

index 5c833b6b21a706a56619f91e5bbc24e517970675..e7f39369a060a00253d32239ebb1fcc2afca53bd 100644 (file)
@@ -3759,15 +3759,15 @@ int main(int argc, const char **argv)
   }
 
   if (format ==  "xml")
-    formatter = make_unique<XMLFormatter>(new XMLFormatter(pretty_format));
+    formatter = make_unique<XMLFormatter>(pretty_format);
   else if (format == "json")
-    formatter = make_unique<JSONFormatter>(new JSONFormatter(pretty_format));
+    formatter = make_unique<JSONFormatter>(pretty_format);
   else {
     cerr << "unrecognized format: " << format << std::endl;
     exit(1);
   }
 
-  zone_formatter = std::make_unique<JSONFormatter_PrettyZone>(new JSONFormatter_PrettyZone(pretty_format));
+  zone_formatter = std::make_unique<JSONFormatter_PrettyZone>(pretty_format);
 
   realm_name = g_conf()->rgw_realm;
   zone_name = g_conf()->rgw_zone;