diff --git a/libraries/libldap/tls_m.c b/libraries/libldap/tls_m.c
index 4b2ecfa..d69b186 100644
--- a/libraries/libldap/tls_m.c
+++ b/libraries/libldap/tls_m.c
@@ -2097,6 +2097,8 @@ tlsm_ctx_free ( tls_ctx *ctx )
 				   "TLS: could not close certdb slot - error %d:%s.\n",
 				   errcode, PR_ErrorToString( errcode, PR_LANGUAGE_I_DEFAULT ), 0 );
 		}
+		PK11_FreeSlot( c->tc_certdb_slot );
+		c->tc_certdb_slot = NULL;
 	}
 	if ( c->tc_pin_file ) {
 		PL_strfree( c->tc_pin_file );
