summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--split.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/split.c b/split.c
index 5366221..81671a7 100644
--- a/split.c
+++ b/split.c
@@ -39,9 +39,12 @@ static char *nextsuffix(size_t n, char s[])
return s;
}
- for (size_t i = n-1; i > 0; i--) {
+ for (size_t i = n - 1; ; i--) {
s[i] = *(strchr(alphabet, s[i]) + 1);
if (s[i] == '\0') {
+ if (i == 0) {
+ return NULL;
+ }
s[i] = alphabet[0];
} else {
break;