color_t: validate hex string input (resolves #9030)
This commit is contained in:
parent
e67a91caf2
commit
6f32635788
1 changed files with 4 additions and 0 deletions
|
@ -65,6 +65,10 @@ color_t color_t::from_hex_string(const std::string& c)
|
|||
throw std::invalid_argument("Color hex string should be exactly 6 digits");
|
||||
}
|
||||
|
||||
if(!std::all_of(c.begin(), c.end(), [](const char& ch) { return std::isxdigit(ch) != 0; })) {
|
||||
throw std::invalid_argument("Color hex string contains invalid characters");
|
||||
}
|
||||
|
||||
unsigned long temp_c = std::strtol(c.c_str(), nullptr, 16);
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Reference in a new issue