summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-07-04 16:47:59 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-07-04 16:47:59 +0000
commit640d8227c9120c12838d68c3985db26ffa19b74b (patch)
treed624d11a82f7eb1f56db9c0c523bec0b7d1b804e
parent350c68e6def3a3db541c916f78260e13925398a4 (diff)
parentfb36128c20efd34067bbcee4f78289671dcd9bd1 (diff)
downloadouroboros-640d8227c9120c12838d68c3985db26ffa19b74b.tar.gz
ouroboros-640d8227c9120c12838d68c3985db26ffa19b74b.zip
Merged in dstaesse/ouroboros/be-cdap-req (pull request #521)
lib: Handle errors when creating cdap_req structs
-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);