diff options
author | Charlie Somerville <charlie@charliesomerville.com> | 2014-01-15 11:38:02 +1100 |
---|---|---|
committer | Charlie Somerville <charlie@charliesomerville.com> | 2014-01-15 11:38:02 +1100 |
commit | 81c95a5fd3eadf51aaeb56524bb9e049cf70a129 (patch) | |
tree | 4a1430e8771e5f8112c0e7f3ec094f6ce4e46761 | |
parent | cc3ee4532533179c589d3f15feb0c76bed96cdb2 (diff) |
sds.c: avoid leaking tokens when seplen < 1 || len < 0
-rw-r--r-- | sds.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; |