Fix memory leaks on 'inf' detected with cppcheck

Only compile tested