mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 18:19:43 +01:00
Add unsigned char static_cast to argument of std::isdigit()
Apparently it results in Undefined Behavior if the argument given isn't representable as an unsigned char. This means that (potentially) plain char and signed chars could be unsafe to use as well. It's rare that this could happen in practice, though. std::isdigit() is only used by is_positive_num() which is only used by find_tag(), so someone would have to deliberately put something crazy after an `&#` in a custom level file in order for this to happen. Still, better to be safe than sorry and all.
This commit is contained in:
parent
fdb44cc209
commit
884035fd2e
1 changed files with 1 additions and 1 deletions
|
@ -213,7 +213,7 @@ bool is_positive_num(const std::string& str)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < str.length(); i++)
|
for (size_t i = 0; i < str.length(); i++)
|
||||||
{
|
{
|
||||||
if (!std::isdigit(str[i]))
|
if (!std::isdigit(static_cast<unsigned char>(str[i])))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue