diff options
-rw-r--r-- | lib/strto.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/strto.c b/lib/strto.c index a6c01574da..e93a4f5491 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -160,9 +160,11 @@ long trailing_strtoln(const char *str, const char *end) if (!end) end = str + strlen(str); - for (p = end - 1; p > str; p--) { - if (!isdigit(*p)) - return simple_strtoul(p + 1, NULL, 10); + if (isdigit(end[-1])) { + for (p = end - 1; p > str; p--) { + if (!isdigit(*p)) + return simple_strtoul(p + 1, NULL, 10); + } } return -1; |