Fixing RESOURCE_LEAK reported by Coverity