fix a memory leak during reconnect