Disconnect before free'ing

This commit is contained in:
Pieter Noordhuis 2010-10-07 17:38:56 +02:00
parent 9cd3b03d84
commit b60952f22a

View File

@ -594,6 +594,11 @@ void redisDisconnect(redisContext *c) {
} }
void redisFree(redisContext *c) { void redisFree(redisContext *c) {
/* Disconnect before free'ing if not yet disconnected. */
if (c->flags & REDIS_CONNECTED)
redisDisconnect(c);
/* Fire free callback and clear all allocations. */
if (c->cbFree != NULL) if (c->cbFree != NULL)
c->cbFree(c,c->privdataFree); c->cbFree(c,c->privdataFree);
if (c->error != NULL) if (c->error != NULL)