From 6f126d809be5e77ab1907c044daa87ed34276cb2 Mon Sep 17 00:00:00 2001 From: Dmitri Tikhonov Date: Mon, 27 Aug 2018 13:55:06 -0400 Subject: [PATCH] 1.12.4: Fix memory leaks and gcc compilation warnings --- CHANGELOG | 7 +++++++ include/lsquic.h | 2 +- src/liblsquic/lsquic_engine.c | 1 + test/http_client.c | 7 +++++++ test/unittests/test_di_nocopy.c | 4 ++-- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 40d107e..e314d6a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +2018-08-27 + + - 1.12.4 + - Fix memory leak when engine is destroyed + - Fix memory leak in http_client + - Fix gcc warning in unit tests + 2018-08-22 - 1.12.3 diff --git a/include/lsquic.h b/include/lsquic.h index f028334..adfc33c 100644 --- a/include/lsquic.h +++ b/include/lsquic.h @@ -25,7 +25,7 @@ extern "C" { #define LSQUIC_MAJOR_VERSION 1 #define LSQUIC_MINOR_VERSION 12 -#define LSQUIC_PATCH_VERSION 3 +#define LSQUIC_PATCH_VERSION 4 /** * Engine flags: diff --git a/src/liblsquic/lsquic_engine.c b/src/liblsquic/lsquic_engine.c index 47fc08d..7cc5a36 100644 --- a/src/liblsquic/lsquic_engine.c +++ b/src/liblsquic/lsquic_engine.c @@ -574,6 +574,7 @@ lsquic_engine_destroy (lsquic_engine_t *engine) assert(0 == lsquic_mh_count(&engine->conns_out)); assert(0 == lsquic_mh_count(&engine->conns_tickable)); + lsquic_mm_cleanup(&engine->pub.enp_mm); free(engine->conns_tickable.mh_elems); free(engine); } diff --git a/test/http_client.c b/test/http_client.c index a4b0829..e7fce99 100644 --- a/test/http_client.c +++ b/test/http_client.c @@ -306,6 +306,7 @@ display_cert_chain (lsquic_conn_t *conn) name = X509_get_subject_name(cert); LSQ_INFO("cert #%u: name: %s", i, X509_NAME_oneline(name, buf, sizeof(buf))); + X509_free(cert); } sk_X509_free(chain); @@ -712,5 +713,11 @@ main (int argc, char **argv) if (promise_fd >= 0) (void) close(promise_fd); + while ((pe = TAILQ_FIRST(&client_ctx.hcc_path_elems))) + { + TAILQ_REMOVE(&client_ctx.hcc_path_elems, pe, next_pe); + free(pe); + } + exit(0 == s ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/test/unittests/test_di_nocopy.c b/test/unittests/test_di_nocopy.c index 3a79f6c..95e52ab 100644 --- a/test/unittests/test_di_nocopy.c +++ b/test/unittests/test_di_nocopy.c @@ -281,8 +281,8 @@ run_di_nocopy_test (const struct nocopy_test *test) { data_frame = di->di_if->di_get_frame(di, nread); assert(data_frame); /* Self-check */ - n_to_read = test->read_until - nread > data_frame->df_size - data_frame->df_read_off - ? data_frame->df_size - data_frame->df_read_off : test->read_until - nread; + n_to_read = test->read_until - nread > (unsigned) data_frame->df_size - data_frame->df_read_off + ? (unsigned) data_frame->df_size - data_frame->df_read_off : test->read_until - nread; data_frame->df_read_off += n_to_read; nread += n_to_read; if (data_frame->df_read_off == data_frame->df_size)