From: Casey Bodley Date: Mon, 1 Feb 2021 21:30:05 +0000 (-0500) Subject: radosgw-admin: fix leaks with make_unique() X-Git-Tag: v17.1.0~3018^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5302c18c7eeda11021714eeb01438f20e580e166;p=ceph.git 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 --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 5c833b6b21a..e7f39369a06 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;