You need to sign in or sign up before continuing.
Unverified Commit b28dbef5 authored by Hongcai Ren's avatar Hongcai Ren Committed by GitHub
Browse files

There is mismach between function sdssplitlen() comments and implementation (#4909)

when count is 0, return NULL
parent 3bcf1084
...@@ -939,15 +939,13 @@ sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *c ...@@ -939,15 +939,13 @@ sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *c
long start = 0, j; long start = 0, j;
sds *tokens; sds *tokens;
if (seplen < 1 || len < 0) return NULL; if (seplen < 1 || len <= 0) {
*count = 0;
return NULL;
}
tokens = s_malloc(sizeof(sds)*slots); tokens = s_malloc(sizeof(sds)*slots);
if (tokens == NULL) return NULL; if (tokens == NULL) return NULL;
if (len == 0) {
*count = 0;
return tokens;
}
for (j = 0; j < (len-(seplen-1)); j++) { for (j = 0; j < (len-(seplen-1)); j++) {
/* make sure there is room for the next element and the final one */ /* make sure there is room for the next element and the final one */
if (slots < elements+2) { if (slots < elements+2) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment