summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-07-04 18:30:30 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-07-04 18:30:30 +0200
commitfb36128c20efd34067bbcee4f78289671dcd9bd1 (patch)
treed624d11a82f7eb1f56db9c0c523bec0b7d1b804e /src/lib
parent2fe2012c843ade7b4f67a3d41ae5a96b18c32399 (diff)
downloadouroboros-fb36128c20efd34067bbcee4f78289671dcd9bd1.tar.gz
ouroboros-fb36128c20efd34067bbcee4f78289671dcd9bd1.zip
lib: Handle errors when creating cdap_req structs
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cdap_req.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/cdap_req.c b/src/lib/cdap_req.c
index bb11dbf6..a89d6b2a 100644
--- a/src/lib/cdap_req.c
+++ b/src/lib/cdap_req.c
@@ -48,12 +48,23 @@ struct cdap_req * cdap_req_create(int fd,
creq->data.data = NULL;
creq->data.len = 0;
+ if (pthread_mutex_init(&creq->lock, NULL)) {
+ free(creq);
+ return NULL;
+ }
+
pthread_condattr_init(&cattr);
#ifndef __APPLE__
pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK);
#endif
- pthread_cond_init(&creq->cond, &cattr);
- pthread_mutex_init(&creq->lock, NULL);
+ if (pthread_cond_init(&creq->cond, &cattr)) {
+ pthread_condattr_destroy(&cattr);
+ pthread_mutex_destroy(&creq->lock);
+ free(creq);
+ return NULL;
+ }
+
+ pthread_condattr_destroy(&cattr);
list_head_init(&creq->next);