Fix memory leaks in test/checkpoint. As reported by Coverity.