Fix possible memory leak when neighbour list construction fails.