From 100664e019c37c85401df6744e85ee64aa35c611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Thor=C3=A9n?= Date: Tue, 2 Jan 2024 01:43:49 +0100 Subject: [PATCH] Fix compilation error where gcc 12.1.0 (MinGW) errors with "writing 1 byte into a region of size 0" --- client/render/Colors.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/render/Colors.cpp b/client/render/Colors.cpp index 0c239e879..e53f55543 100644 --- a/client/render/Colors.cpp +++ b/client/render/Colors.cpp @@ -29,11 +29,11 @@ std::optional Colors::parseColor(std::string text) { std::smatch match; std::regex expr("^#([0-9a-fA-F]{6})$"); - ui8 rgb[3] = {0, 0, 0}; + std::vector rgb; + rgb.reserve(3); if(std::regex_search(text, match, expr)) { - std::string tmp = boost::algorithm::unhex(match[1].str()); - std::copy(tmp.begin(), tmp.end(), rgb); + boost::algorithm::unhex(match[1].str(), std::back_inserter(rgb)); return ColorRGBA(rgb[0], rgb[1], rgb[2]); } @@ -42,8 +42,7 @@ std::optional Colors::parseColor(std::string text) for(auto & color : colors) { if(boost::algorithm::to_lower_copy(color.first) == boost::algorithm::to_lower_copy(text)) { - std::string tmp = boost::algorithm::unhex(color.second.String()); - std::copy(tmp.begin(), tmp.end(), rgb); + boost::algorithm::unhex(color.second.String(), std::back_inserter(rgb)); return ColorRGBA(rgb[0], rgb[1], rgb[2]); } }