aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/strto.c2
-rw-r--r--test/str_ut.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/strto.c b/lib/strto.c
index 72903a5..5388672 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -18,7 +18,7 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
{
if (*base == 0) {
if (s[0] == '0') {
- if (tolower(s[1]) == 'x' && isxdigit(s[2]))
+ if (tolower(s[1]) == 'x')
*base = 16;
else
*base = 8;
diff --git a/test/str_ut.c b/test/str_ut.c
index 19f2c12..8133b21 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -84,6 +84,8 @@ static int str_simple_strtoul(struct unit_test_state *uts)
/* Base 10 and base 16 */
ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper));
ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper));
+ ut_assertok(run_strtoul(uts, str3, 16, 0xb, 3, upper));
+ ut_assertok(run_strtoul(uts, str3, 10, 0, 1, upper));
/* Invalid string */
ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper));