Commit c501dabf authored by Peter Hutterer's avatar Peter Hutterer

util: check for < 0 explicitly in safe_atou

The previous check only worked if sizeof(long) > sizeof(int). Rather than be
fancy about it, just cast to a signed long, check for negativity and continue
based on that.

Fixes #137Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent d616218c
......@@ -538,7 +538,7 @@ safe_atou_base(const char *str, unsigned int *val, int base)
if (*str != '\0' && *endptr != '\0')
return false;
if (v > UINT_MAX)
if ((long)v < 0)
return false;
*val = v;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment