From 81c95a5fd3eadf51aaeb56524bb9e049cf70a129 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 15 Jan 2014 11:38:02 +1100 Subject: sds.c: avoid leaking tokens when seplen < 1 || len < 0 --- sds.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3 From 070da2162364100c4069a1842b2641ab95b46a1a Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 15 Jan 2014 11:38:45 +1100 Subject: async.c: avoid a NULL deref when redisAsyncInitialize returns NULL --- async.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/async.c b/async.c index 6532712..923a329 100644 --- a/async.c +++ b/async.c @@ -174,6 +174,11 @@ redisAsyncContext *redisAsyncConnectUnix(const char *path) { return NULL; ac = redisAsyncInitialize(c); + if (ac == NULL) { + redisFree(c); + return NULL; + } + __redisAsyncCopyError(ac); return ac; } @@ -398,7 +403,7 @@ void redisProcessCallbacks(redisAsyncContext *ac) { __redisAsyncDisconnect(ac); return; } - + /* If monitor mode, repush callback */ if(c->flags & REDIS_MONITORING) { __redisPushCallback(&ac->replies,&cb); -- cgit v1.2.3