Fix potential segfault when authentication fails during the descovery step

I don't know why, but this only happened on jenkins for the "legacy build", which made 5 tests in auth-replicaset fail.