mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
There is mismach between function sdssplitlen() comments and implementation (#4909)
when count is 0, return NULL
This commit is contained in:
parent
3bcf108416
commit
b28dbef59d
10
src/sds.c
10
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user