aboutsummaryrefslogtreecommitdiff
path: root/src/im-zmq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/im-zmq.c')
-rw-r--r--src/im-zmq.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/im-zmq.c b/src/im-zmq.c
index c2d386cf..4273b600 100644
--- a/src/im-zmq.c
+++ b/src/im-zmq.c
@@ -68,7 +68,10 @@ struct im_zmq *im_zmq_connect(const char *zmq_address,
if ( z == NULL ) return NULL;
z->ctx = zmq_ctx_new();
- if ( z->ctx == NULL ) return NULL;
+ if ( z->ctx == NULL ) {
+ free(z);
+ return NULL;
+ }
if ( zmq_request == NULL ) {
STATUS("Connecting ZMQ subscriber to '%s'\n", zmq_address);
@@ -77,10 +80,14 @@ struct im_zmq *im_zmq_connect(const char *zmq_address,
STATUS("Connecting ZMQ requester to '%s'\n", zmq_address);
z->socket = zmq_socket(z->ctx, ZMQ_REQ);
}
- if ( z->socket == NULL ) return NULL;
+ if ( z->socket == NULL ) {
+ free(z);
+ return NULL;
+ }
if ( zmq_connect(z->socket, zmq_address) == -1 ) {
ERROR("ZMQ connection failed: %s\n", zmq_strerror(errno));
+ free(z);
return NULL;
}