summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-06-12 20:15:57 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-06-12 21:03:37 +0800
commitdf04b4107f15f49687b8db549ec809517833a120 (patch)
tree3cf3fc79bf01ad809b60aced1ff18615442faa91
parent0562ea18cde243c1151ec9e49fef8408980d2dfa (diff)
fix: compiling with -O0 caused runtime error with `str.back()` so we check if .empty() first
-rw-r--r--src/format.hpp2
1 files changed, 1 insertions, 1 deletions
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;