Fix memleak revealed by Coverity Scan