Permalink
Browse files

Fixed a problem with string2ll()

  • Loading branch information...
1 parent c772d9c commit 5cbe90dbfd5d9f46f5fa42e4e96a40a46d29b234 @antirez committed May 1, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/util.c
View
@@ -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;
}

0 comments on commit 5cbe90d

Please sign in to comment.