mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 14:46:49 +01:00
Merge pull request #785 from lioncash/string
Common: Fix AsciiToHex returning true on overflow values
This commit is contained in:
commit
43010818fa
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user