resource leak fix from Coverity Scan