fix resource leak, coverity issue #1121924