Fix resource leak pointed out by Coverity.