summaryrefslogtreecommitdiff
path: root/src/sds.c
diff options
context:
space:
mode:
authorHongcai Ren <renhongcai@huawei.com>2021-12-22 16:00:21 +0800
committerGitHub <noreply@github.com>2021-12-22 10:00:21 +0200
commitb28dbef59dcbf976822f2ff86d67af372b92d11a (patch)
treef9302ca852ebf2515ee1b65c1c2d5f7a7b6b4395 /src/sds.c
parent3bcf108416bea7ec700aeee2f79e8b31de35c060 (diff)
downloadredis-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.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/sds.c b/src/sds.c
index 280f3ded8..a625c66b7 100644
--- a/src/sds.c
+++ b/src/sds.c
@@ -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) {