defensive programming: set o->ptr to NULL before freeing objects

This commit is contained in:
antirez 2010-07-22 15:48:57 +02:00
parent e002ec6801
commit 2f996f0217

View File

@ -179,6 +179,7 @@ void decrRefCount(void *obj) {
case REDIS_HASH: freeHashObject(o); break;
default: redisPanic("Unknown object type"); break;
}
o->ptr = NULL; /* defensive programming. We'll see NULL in traces. */
if (server.vm_enabled) pthread_mutex_lock(&server.obj_freelist_mutex);
if (listLength(server.objfreelist) > REDIS_OBJFREELIST_MAX ||
!listAddNodeHead(server.objfreelist,o))