Fix some leaks reported by coverity

Long time no see, please review.