From 4d453a65e6728760d3eeb0e88ea2ad8a49d790e1 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 21 Feb 2025 23:31:51 -0700 Subject: [PATCH] fix bug in utils::strcompress() calling back() on empty strings is undefined behavior. --- src/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.cpp b/src/utils.cpp index 310669c241..7daa5ee227 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -156,7 +156,7 @@ std::string utils::strcompress(const std::string &text) } // remove trailing blank - if (output.back() == ' ') output.erase(output.size() - 1, 1); + if (!output.empty() && output.back() == ' ') output.erase(output.size() - 1, 1); return output; }