From: Yuval Lifshitz Date: Tue, 20 Jun 2023 10:21:33 +0000 (+0000) Subject: rgw/kafka: fix potential memory leak when push to queue fails X-Git-Tag: v19.0.0~985^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F52129%2Fhead;p=ceph.git rgw/kafka: fix potential memory leak when push to queue fails Signed-off-by: Yuval Lifshitz --- diff --git a/src/rgw/rgw_kafka.cc b/src/rgw/rgw_kafka.cc index 678e6d62bfe9..832c4667b94e 100644 --- a/src/rgw/rgw_kafka.cc +++ b/src/rgw/rgw_kafka.cc @@ -602,7 +602,9 @@ public: if (stopped) { return STATUS_MANAGER_STOPPED; } - if (messages.push(new message_wrapper_t(conn_name, topic, message, nullptr))) { + auto message_wrapper = std::make_unique(conn_name, topic, message, nullptr); + if (messages.push(message_wrapper.get())) { + std::ignore = message_wrapper.release(); ++queued; return STATUS_OK; } @@ -616,7 +618,9 @@ public: if (stopped) { return STATUS_MANAGER_STOPPED; } - if (messages.push(new message_wrapper_t(conn_name, topic, message, cb))) { + auto message_wrapper = std::make_unique(conn_name, topic, message, cb); + if (messages.push(message_wrapper.get())) { + std::ignore = message_wrapper.release(); ++queued; return STATUS_OK; }