Unified handling of empty queries with normal queries.
[redis.git] / sds.c
diff --git a/sds.c b/sds.c
index 8e9fd96d9befd2a4b4b7eb7ca9317001df24f8b8..6d18d1fd008b18e5e6de7785ecb47224aa04efe7 100644 (file)
--- a/sds.c
+++ b/sds.c
@@ -277,6 +277,10 @@ sds *sdssplitlen(char *s, int len, char *sep, int seplen, int *count) {
     if (tokens == NULL) sdsOomAbort();
 #endif
     if (seplen < 1 || len < 0 || tokens == NULL) return NULL;
+    if (len == 0) {
+        *count = 0;
+        return tokens;
+    }
     for (j = 0; j < (len-(seplen-1)); j++) {
         /* make sure there is room for the next element and the final one */
         if (slots < elements+2) {