From df04b4107f15f49687b8db549ec809517833a120 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 12 Jun 2025 20:15:57 +0800 Subject: fix: compiling with -O0 caused runtime error with `str.back()` so we check if .empty() first --- src/format.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/format.hpp b/src/format.hpp index 40e85f3..f857f96 100644 --- a/src/format.hpp +++ b/src/format.hpp @@ -38,7 +38,7 @@ inline std::string fmt(eFormatType type, std::string str) { break; } - if (str.back() != '\n' && type != NONEWLINE) + if (!str.empty() && str.back() != '\n' && type != NONEWLINE) str += '\n'; return prefix + str; -- cgit v1.2.3