Skip to content

Commit 5b44c97

Browse files
committed
fix #141: Check digits when converting string to long
1 parent 3e7ca1f commit 5b44c97

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/scratchcpp/value.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,14 @@ class LIBSCRATCHCPP_EXPORT Value : public ValueVariant
660660
return 0;
661661
}
662662

663+
static const std::string digits = "0123456789+-";
664+
665+
for (char c : s) {
666+
if (digits.find(c) == std::string::npos) {
667+
return 0;
668+
}
669+
}
670+
663671
try {
664672
if (ok)
665673
*ok = true;

0 commit comments

Comments
 (0)