summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sds.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sds.c b/sds.c
index 9226799..998564d 100644
--- a/sds.c
+++ b/sds.c
@@ -295,7 +295,11 @@ sds *sdssplitlen(char *s, int len, char *sep, int seplen, int *count) {
#ifdef SDS_ABORT_ON_OOM
if (tokens == NULL) sdsOomAbort();
#endif
- if (seplen < 1 || len < 0 || tokens == NULL) return NULL;
+ if (tokens == NULL) return NULL;
+ if (seplen < 1 || len < 0) {
+ free(tokens);
+ return NULL;
+ }
if (len == 0) {
*count = 0;
return tokens;