mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +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::smatch match;
|
||||||
std::regex expr("^#([0-9a-fA-F]{6})$");
|
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))
|
if(std::regex_search(text, match, expr))
|
||||||
{
|
{
|
||||||
std::string tmp = boost::algorithm::unhex(match[1].str());
|
boost::algorithm::unhex(match[1].str(), std::back_inserter(rgb));
|
||||||
std::copy(tmp.begin(), tmp.end(), rgb);
|
|
||||||
return ColorRGBA(rgb[0], rgb[1], rgb[2]);
|
return ColorRGBA(rgb[0], rgb[1], rgb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +42,7 @@ std::optional<ColorRGBA> Colors::parseColor(std::string text)
|
|||||||
for(auto & color : colors) {
|
for(auto & color : colors) {
|
||||||
if(boost::algorithm::to_lower_copy(color.first) == boost::algorithm::to_lower_copy(text))
|
if(boost::algorithm::to_lower_copy(color.first) == boost::algorithm::to_lower_copy(text))
|
||||||
{
|
{
|
||||||
std::string tmp = boost::algorithm::unhex(color.second.String());
|
boost::algorithm::unhex(color.second.String(), std::back_inserter(rgb));
|
||||||
std::copy(tmp.begin(), tmp.end(), rgb);
|
|
||||||
return ColorRGBA(rgb[0], rgb[1], rgb[2]);
|
return ColorRGBA(rgb[0], rgb[1], rgb[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user