From 884035fd2eeac6784136d56a69b9882108df3f61 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 12 Jun 2020 10:48:41 -0700 Subject: [PATCH] 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. --- desktop_version/src/UtilityClass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/UtilityClass.cpp b/desktop_version/src/UtilityClass.cpp index 06859db2..ca5b9c47 100644 --- a/desktop_version/src/UtilityClass.cpp +++ b/desktop_version/src/UtilityClass.cpp @@ -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(str[i]))) { return false; }