aboutsummaryrefslogtreecommitdiff
path: root/src/im-zmq.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-07-21 11:51:56 +0200
committerThomas White <taw@physics.org>2021-07-21 15:34:31 +0200
commit6d94d4115c254d344bbb927596a7141ef39fd298 (patch)
tree652d07c4d6a9521c9359aa13bbda27309f53e6f8 /src/im-zmq.c
parent50cf52b0bc0baa683b9508568131a3f6281bf4ff (diff)
Add missing cleanup on error paths
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;
}