mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fix compilation error where gcc 12.1.0 (MinGW) errors with "writing 1 byte into a region of size 0"
This commit is contained in:
@@ -29,11 +29,11 @@ std::optional<ColorRGBA> Colors::parseColor(std::string text)
|
||||
{
|
||||
std::smatch match;
|
||||
std::regex expr("^#([0-9a-fA-F]{6})$");
|
||||
ui8 rgb[3] = {0, 0, 0};
|
||||
std::vector<ui8> 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<ColorRGBA> 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]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user