[llvm] [clang-tools-extra] [clang] [Support] Trim trailing null character in PrettyStackTraceFormat. (PR #77351)

Jon Ross-Perkins via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 12:16:02 PST 2024


https://github.com/jonmeow updated https://github.com/llvm/llvm-project/pull/77351

>From c090ffd9d62a8e17a757c807d010d2e0d7907e16 Mon Sep 17 00:00:00 2001
From: jonmeow <jperkins at google.com>
Date: Mon, 8 Jan 2024 10:26:09 -0800
Subject: [PATCH] [Support] Trim trailing null character in
 PrettyStackTraceFormat.

---
 llvm/lib/Support/PrettyStackTrace.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Support/PrettyStackTrace.cpp b/llvm/lib/Support/PrettyStackTrace.cpp
index f9f1b8a419b820..fc3e08e3662217 100644
--- a/llvm/lib/Support/PrettyStackTrace.cpp
+++ b/llvm/lib/Support/PrettyStackTrace.cpp
@@ -249,6 +249,8 @@ PrettyStackTraceFormat::PrettyStackTraceFormat(const char *Format, ...) {
   va_start(AP, Format);
   vsnprintf(Str.data(), Size, Format, AP);
   va_end(AP);
+  // Remove the '\0' for printing.
+  Str.pop_back();
 }
 
 void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str << "\n"; }



More information about the cfe-commits mailing list