From 5cbe90dbfd5d9f46f5fa42e4e96a40a46d29b234 Mon Sep 17 00:00:00 2001 From: antirez Date: Sun, 1 May 2011 15:36:47 +0200 Subject: [PATCH] Fixed a problem with string2ll() --- src/util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index 599dc690..2404c77c 100644 --- a/src/util.c +++ b/src/util.c @@ -222,10 +222,13 @@ int string2ll(char *s, size_t slen, long long *value) { return 0; } - /* First digit should be 1-9. */ + /* First digit should be 1-9, otherwise the string should just be 0. */ if (p[0] >= '1' && p[0] <= '9') { v = p[0]-'0'; p++; plen++; + } else if (p[0] == '0' && slen == 1) { + *value = 0; + return 1; } else { return 0; }