PROTON-1804: Fix memory leak found by fuzz tester
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/99b1d7f5 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/99b1d7f5 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/99b1d7f5 Branch: refs/heads/go1 Commit: 99b1d7f5dc5107e690a83a91252c59cff6426619 Parents: ae7c3a8 Author: Andrew Stitcher <astitc...@apache.org> Authored: Wed Mar 21 20:22:04 2018 -0400 Committer: Andrew Stitcher <astitc...@apache.org> Committed: Wed Mar 21 23:56:40 2018 -0400 ---------------------------------------------------------------------- proton-c/src/core/transport.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99b1d7f5/proton-c/src/core/transport.c ---------------------------------------------------------------------- diff --git a/proton-c/src/core/transport.c b/proton-c/src/core/transport.c index 2090a91..0d18f72 100644 --- a/proton-c/src/core/transport.c +++ b/proton-c/src/core/transport.c @@ -1196,16 +1196,10 @@ int pn_do_open(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, transport->remote_max_frame = AMQP_MIN_MAX_FRAME_SIZE; } } - if (container_q) { - transport->remote_container = pn_bytes_strdup(remote_container); - } else { - transport->remote_container = NULL; - } - if (hostname_q) { - transport->remote_hostname = pn_bytes_strdup(remote_hostname); - } else { - transport->remote_hostname = NULL; - } + free(transport->remote_container); + transport->remote_container = container_q ? pn_bytes_strdup(remote_container) : NULL; + free(transport->remote_hostname); + transport->remote_hostname = hostname_q ? pn_bytes_strdup(remote_hostname) : NULL; if (conn) { PN_SET_REMOTE(conn->endpoint.state, PN_REMOTE_ACTIVE); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org