[12363] Fix hidden memleak with waypoints

Thanks to rsa for pointing

(based on commit [12260] - eeff1c0)