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:
parent
b6a860795c
commit
d1e820d8ee
@ -1059,6 +1059,12 @@ static redisContext *redisContextInit(void) {
|
|||||||
c->errstr[0] = '\0';
|
c->errstr[0] = '\0';
|
||||||
c->obuf = sdsempty();
|
c->obuf = sdsempty();
|
||||||
c->reader = redisReaderCreate();
|
c->reader = redisReaderCreate();
|
||||||
|
|
||||||
|
if (c->obuf == NULL || c->reader == NULL) {
|
||||||
|
redisFree(c);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user