diff options
| author | shuffle2 <godisgovernment@gmail.com> | 2014-08-12 14:43:02 -0700 |
|---|---|---|
| committer | shuffle2 <godisgovernment@gmail.com> | 2014-08-12 14:43:02 -0700 |
| commit | 43010818fad592d1af046368fe9a5175ccba3975 (patch) | |
| tree | f1d7ec5be07dd7c034e7ba9d93d3eacb07adac36 /Source/Core/Common/StringUtil.cpp | |
| parent | 9f4008c5bc268ba9428b12d2eb26d17c976d3398 (diff) | |
| parent | 5afb9cc5c44ea143141689e26f84fc7036accb7e (diff) | |
Merge pull request #785 from lioncash/string
Common: Fix AsciiToHex returning true on overflow values
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 16281ac91f..59fcb4131d 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -28,12 +28,18 @@ // faster than sscanf bool AsciiToHex(const std::string& _szValue, u32& result) { + // Set errno to a good state. + errno = 0; + char *endptr = nullptr; const u32 value = strtoul(_szValue.c_str(), &endptr, 16); if (!endptr || *endptr) return false; + if (errno == ERANGE) + return false; + result = value; return true; } |
