fix memory leak
this was previously incorrectly fixed in a6744b81777ab8247908350bd15cca49bedf5208