Fix resource leak detected by coverity
CID 26253, 26273, 26222, 26221, 26220