From 5302c18c7eeda11021714eeb01438f20e580e166 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 1 Feb 2021 16:30:05 -0500 Subject: [PATCH] radosgw-admin: fix leaks with make_unique() `make_unique(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 --- src/rgw/rgw_admin.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 5c833b6b21a7..e7f39369a060 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -3759,15 +3759,15 @@ int main(int argc, const char **argv) } if (format == "xml") - formatter = make_unique(new XMLFormatter(pretty_format)); + formatter = make_unique(pretty_format); else if (format == "json") - formatter = make_unique(new JSONFormatter(pretty_format)); + formatter = make_unique(pretty_format); else { cerr << "unrecognized format: " << format << std::endl; exit(1); } - zone_formatter = std::make_unique(new JSONFormatter_PrettyZone(pretty_format)); + zone_formatter = std::make_unique(pretty_format); realm_name = g_conf()->rgw_realm; zone_name = g_conf()->rgw_zone; -- 2.47.3