diff options
| author | Lioncash <mathew1800@gmail.com> | 2014-08-12 02:48:52 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2014-08-12 02:49:04 -0400 |
| commit | 5afb9cc5c44ea143141689e26f84fc7036accb7e (patch) | |
| tree | b5f6455f15adff1982da8d73c277feaa546693cb /Source/Core/Common/StringUtil.cpp | |
| parent | 36af1b518df483bdace54485861ff459e02a90a6 (diff) | |
Common: Fix AsciiToHex returning true on overflow values
We should be checking errno against ERANGE.
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; } |
