fix memleak that got introduced in 5.1.0