Skip to content

Commit

Permalink
sds.c: avoid leaking tokens when seplen < 1 || len < 0
Browse files Browse the repository at this point in the history
Charlie Somerville committed Jan 15, 2014

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent cc3ee45 commit 81c95a5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sds.c
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 81c95a5

Please sign in to comment.