Skip to content

Commit

Permalink
ZMQ: fixed some memory leaks in the source
Browse files Browse the repository at this point in the history
  • Loading branch information
Laszlo Meszaros committed Jan 19, 2015
1 parent 053b6ee commit 20ce08a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions modules/zmq/zmq-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ create_zmq_context(ZMQSourceDriver* self)
return FALSE;
}

if (zmq_bind(self->socket, get_address(self)) != 0)
gchar* address = get_address(self);

if (zmq_bind(self->socket, address) != 0)
{
msg_error("Failed to bind!", evt_tag_str("Bind address", get_address(self)), evt_tag_errno("Error", errno),NULL);
msg_error("Failed to bind!", evt_tag_str("Bind address", address), evt_tag_errno("Error", errno),NULL);
g_free(address);
return FALSE;
}

g_free(address);
return TRUE;
}

Expand All @@ -126,7 +130,11 @@ zmq_sd_init(LogPipe *s)
return FALSE;
}

ZMQReaderContext* reader_context = cfg_persist_config_fetch(cfg, get_persist_name(self));
gchar* persist_name = get_persist_name(self);

ZMQReaderContext* reader_context = cfg_persist_config_fetch(cfg, persist_name);

g_free(persist_name);

log_reader_options_init(&self->reader_options, cfg, "zmq");

Expand Down Expand Up @@ -188,7 +196,11 @@ zmq_sd_deinit(LogPipe *s)
self->context = NULL;
self->reader = NULL;

cfg_persist_config_add(cfg, get_persist_name(self), reader_context, (GDestroyNotify) zmq_socket_deinit, FALSE);
gchar* persist_name = get_persist_name(self);

cfg_persist_config_add(cfg, persist_name, reader_context, (GDestroyNotify) zmq_socket_deinit, FALSE);

g_free(persist_name);

return log_src_driver_deinit_method(s);
}
Expand Down

0 comments on commit 20ce08a

Please sign in to comment.