diff options
author | Stef Walter <stefw@collabora.co.uk> | 2011-05-26 09:58:56 +0200 |
---|---|---|
committer | Stef Walter <stefw@collabora.co.uk> | 2011-05-26 09:58:56 +0200 |
commit | c37d5dfaf0c2a5e70066fd1c9606b00329c3622a (patch) | |
tree | 3f0123537aa65947e544997f1443bd3fcb40a01c /p11-kit | |
parent | 0542a87afdacd2c53da5d453b1d23e8a0dd91ea4 (diff) |
Return proper errors when NULL is passed to mutex functions.
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/p11-kit-lib.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/p11-kit/p11-kit-lib.c b/p11-kit/p11-kit-lib.c index 59cdd19..abc58f8 100644 --- a/p11-kit/p11-kit-lib.c +++ b/p11-kit/p11-kit-lib.c @@ -197,6 +197,9 @@ create_mutex (CK_VOID_PTR_PTR mut) pthread_mutex_t *pmutex; int err; + if (mut == NULL) + return CKR_ARGUMENTS_BAD; + pmutex = malloc (sizeof (pthread_mutex_t)); if (!pmutex) return CKR_HOST_MEMORY; @@ -215,6 +218,9 @@ destroy_mutex (CK_VOID_PTR mut) pthread_mutex_t *pmutex = mut; int err; + if (mut == NULL) + return CKR_MUTEX_BAD; + err = pthread_mutex_destroy (pmutex); if (err == EINVAL) return CKR_MUTEX_BAD; @@ -230,6 +236,9 @@ lock_mutex (CK_VOID_PTR mut) pthread_mutex_t *pmutex = mut; int err; + if (mut == NULL) + return CKR_MUTEX_BAD; + err = pthread_mutex_lock (pmutex); if (err == EINVAL) return CKR_MUTEX_BAD; @@ -244,6 +253,9 @@ unlock_mutex (CK_VOID_PTR mut) pthread_mutex_t *pmutex = mut; int err; + if (mut == NULL) + return CKR_MUTEX_BAD; + err = pthread_mutex_unlock (pmutex); if (err == EINVAL) return CKR_MUTEX_BAD; |