[Fix] Fix two memory leaks

I know but IMO the if makes it more obvious that it will not always be deleted. Especially in this case which probably happens very few times.