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 <sunyuechi@iscas.ac.cn>
This commit is contained in:
Sun Yuechi 2026-07-01 02:59:15 -07:00
parent ef0b9f339f
commit 0ea4eb19b0

View File

@ -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;
}
}