diff options
author | Hongcai Ren <renhongcai@huawei.com> | 2021-12-22 16:00:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-22 10:00:21 +0200 |
commit | b28dbef59dcbf976822f2ff86d67af372b92d11a (patch) | |
tree | f9302ca852ebf2515ee1b65c1c2d5f7a7b6b4395 /src/sds.c | |
parent | 3bcf108416bea7ec700aeee2f79e8b31de35c060 (diff) | |
download | redis-b28dbef59dcbf976822f2ff86d67af372b92d11a.tar.gz |
There is mismach between function sdssplitlen() comments and implementation (#4909)
when count is 0, return NULL
Diffstat (limited to 'src/sds.c')
-rw-r--r-- | src/sds.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -939,15 +939,13 @@ sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *c long start = 0, j; sds *tokens; - if (seplen < 1 || len < 0) return NULL; - + if (seplen < 1 || len <= 0) { + *count = 0; + return NULL; + } tokens = s_malloc(sizeof(sds)*slots); if (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) { |