test: testConnectAuthenticate: Take the lock when accessing mutable values

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Marc Hartmayer 2018-03-08 13:20:31 +01:00 committed by John Ferlan
parent ba8bd17a6a
commit 5428389b2b

View File

@ -1369,8 +1369,11 @@ testConnectAuthenticate(virConnectPtr conn,
ssize_t i;
char *username = NULL, *password = NULL;
if (privconn->numAuths == 0)
testDriverLock(privconn);
if (privconn->numAuths == 0) {
testDriverUnlock(privconn);
return 0;
}
/* Authentication is required because the test XML contains a
* non-empty <auth/> section. First we must ask for a username.
@ -1410,6 +1413,7 @@ testConnectAuthenticate(virConnectPtr conn,
ret = 0;
cleanup:
testDriverUnlock(privconn);
VIR_FREE(username);
VIR_FREE(password);
return ret;