Fix memory leak when creating a socket fails.

Previously, AddressSanitizer flagged leaks when running
tests/test_many_sockets.cpp.
This commit is contained in:
Brian Silverman
2015-07-22 11:18:48 -07:00
parent c05a475bf7
commit 773a06fc23
2 changed files with 28 additions and 16 deletions

View File

@@ -154,8 +154,11 @@ zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,
mailbox_t *mailbox = dynamic_cast<mailbox_t*> (s->mailbox);
if (mailbox != NULL && mailbox->get_fd () == retired_fd)
if (mailbox != NULL && mailbox->get_fd () == retired_fd) {
s->destroyed = true;
delete s;
return NULL;
}
return s;
}