PR#3342 fix resource leak coverity issue 966577 and 966576