https://github.com/jsji created https://github.com/llvm/llvm-project/pull/191711
Fix 136-byte memory leak introduced in commit 6dc059ac3c7c. Before that commit, the TextDiagnosticBuffer was passed to DiagnosticsEngine constructor which took ownership and managed its lifetime. After the refactoring, the buffer is no longer passed to DiagnosticsEngine, so it becomes an orphaned allocation that is never freed. Changed to use std::unique_ptr for automatic cleanup. >From 14bad1e115ab4f7c62bdfcb5534a736758e61aad Mon Sep 17 00:00:00 2001 From: Jinsong Ji <[email protected]> Date: Sun, 12 Apr 2026 15:36:55 +0200 Subject: [PATCH] [Clang][diagtool] Fix memory leak in ShowEnabledWarnings Fix 136-byte memory leak introduced in commit 6dc059ac3c7c. Before that commit, the TextDiagnosticBuffer was passed to DiagnosticsEngine constructor which took ownership and managed its lifetime. After the refactoring, the buffer is no longer passed to DiagnosticsEngine, so it becomes an orphaned allocation that is never freed. Changed to use std::unique_ptr for automatic cleanup. --- clang/tools/diagtool/ShowEnabledWarnings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/tools/diagtool/ShowEnabledWarnings.cpp b/clang/tools/diagtool/ShowEnabledWarnings.cpp index a0c593a3a9105..634f1d53eaaeb 100644 --- a/clang/tools/diagtool/ShowEnabledWarnings.cpp +++ b/clang/tools/diagtool/ShowEnabledWarnings.cpp @@ -58,7 +58,8 @@ static IntrusiveRefCntPtr<DiagnosticsEngine> createDiagnostics(unsigned int argc, char **argv) { // Buffer diagnostics from argument parsing so that we can output them using a // well formed diagnostic object. - TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer; + std::unique_ptr<TextDiagnosticBuffer> DiagsBuffer = + std::make_unique<TextDiagnosticBuffer>(); // Try to build the diagnostics parser SmallVector<const char *, 4> Args; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
