From 0ea4eb19b0f1eb234cfb381f79cd0f39bf654adf Mon Sep 17 00:00:00 2001 From: Sun Yuechi Date: Wed, 1 Jul 2026 02:59:15 -0700 Subject: [PATCH] tools/rados: fix leaked/unflushed output stream in 'ls' `if (!stdout)` tested the libc FILE* (never null) instead of the use_stdout flag, so the ofstream was never deleted when writing to a file, leaking it and leaving its buffer unflushed. Test use_stdout. Signed-off-by: Sun Yuechi --- src/tools/rados/rados.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 118359be582..81ef10f6fd8 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -2581,7 +2581,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } formatter->flush(*outstream); } - if (!stdout) { + if (!use_stdout) { delete outstream; } }