Add error check in redisContextInit

Check whether the obuf or reader is empty: if one of the items is empty,
free the redisContext.
This commit is contained in:
NanXiao 2014-07-14 14:33:16 +08:00 committed by Matt Stancliff
parent b6a860795c
commit d1e820d8ee
1 changed files with 6 additions and 0 deletions

View File

@ -1059,6 +1059,12 @@ static redisContext *redisContextInit(void) {
c->errstr[0] = '\0';
c->obuf = sdsempty();
c->reader = redisReaderCreate();
if (c->obuf == NULL || c->reader == NULL) {
redisFree(c);
return NULL;
}
return c;
}