diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-06-12 20:15:57 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-06-12 21:03:37 +0800 |
| commit | df04b4107f15f49687b8db549ec809517833a120 (patch) | |
| tree | 3cf3fc79bf01ad809b60aced1ff18615442faa91 | |
| parent | 0562ea18cde243c1151ec9e49fef8408980d2dfa (diff) | |
fix: compiling with -O0 caused runtime error with `str.back()` so we check if .empty() first
| -rw-r--r-- | src/format.hpp | 2 |
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; |
