datpath: Fix memory leak when a loop is detected.