1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09: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:
Misa 2020-06-12 10:48:41 -07:00 committed by Ethan Lee
parent fdb44cc209
commit 884035fd2e

View file

@ -213,7 +213,7 @@ bool is_positive_num(const std::string& str)
{
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;
}