GUACAMOLE-157: Initialize SSH SSL lock array to NULL and test for NULL-ness before freeing.

This commit is contained in:
Frode Langelo 2017-01-11 22:40:34 +00:00
parent 6d4b7a94f6
commit 6c05dc026e

View File

@ -48,7 +48,7 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
/**
* Array of mutexes, used by OpenSSL.
*/
static pthread_mutex_t* guac_common_ssh_openssl_locks;
static pthread_mutex_t* guac_common_ssh_openssl_locks = NULL;
/**
* Called by OpenSSL when locking or unlocking the Nth mutex.
@ -103,7 +103,7 @@ static void guac_common_ssh_openssl_init_locks(int count) {
/* Allocate required number of locks */
guac_common_ssh_openssl_locks =
malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
malloc(sizeof(pthread_mutex_t) * count);
/* Initialize each lock */
for (i=0; i < count; i++)
@ -121,6 +121,10 @@ static void guac_common_ssh_openssl_free_locks(int count) {
int i;
/* SSL lock array was not initialized */
if (guac_common_ssh_openssl_locks == NULL)
return;
/* Free all locks */
for (i=0; i < count; i++)
pthread_mutex_destroy(&(guac_common_ssh_openssl_locks[i]));