add memleak fix from commit ccbb1f15