fix for memory leak spotted by liu (644531343@qq.com)