From b60952f22ade00bebd08530e568ed31eeadd8797 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 7 Oct 2010 17:38:56 +0200 Subject: Disconnect before free'ing --- hiredis.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hiredis.c b/hiredis.c index 2d897d5..662bdae 100644 --- a/hiredis.c +++ b/hiredis.c @@ -594,6 +594,11 @@ void redisDisconnect(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) c->cbFree(c,c->privdataFree); if (c->error != NULL) -- cgit v1.2.3