From 50aa4097bb34c245241fdbee5b69b9f641c43945 Mon Sep 17 00:00:00 2001 From: Caball Date: Mon, 30 Dec 2024 23:22:34 +0100 Subject: [PATCH] Fixed two bugs in the old color strip function. --- src/common/utils/string.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index 2e0bbad..496cad3 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -115,13 +115,13 @@ namespace utils::string void strip(const char* in, char* out, size_t max) { - if (!in || !out) return; + if (!in || !out || !max) return; max--; auto current = 0u; while (*in != 0 && current < max) { - const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48); + const auto color_index = (static_cast(*(in + 1) - 48)) >= 0xC ? 7 : (*(in + 1) - 48); if (*in == '^' && (color_index != 7 || *(in + 1) == '7')) {