Corrected a double-free issue reported by Coverity.