PR#3342 fix resource leak coverity issue 966577