Fix high severity memory leak