From f6b6476ca412d602db5a87185659f07142e6d3fe Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 6 Sep 2024 10:45:34 +0200 Subject: [PATCH 1/2] clar: fix leaking error reports We never free error reports when some of the tests have failed or issued warnings. Plug this memory leak. --- clar.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clar.c b/clar.c index 6022400..481713d 100644 --- a/clar.c +++ b/clar.c @@ -635,6 +635,14 @@ clar_test_shutdown(void) } for (report = _clar.reports; report; report = report_next) { + struct clar_error *error, *error_next; + + for (error = report->errors; error; error = error_next) { + free(error->description); + error_next = error->next; + free(error); + } + report_next = report->next; free(report); } From 2ff1c51a863e43ebf85f6b2c915926c386533f67 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 6 Sep 2024 10:48:37 +0200 Subject: [PATCH 2/2] ci: add job checking for memory leaks Add a CI job that exercises the clar for memory leaks. --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54674a0..aae853b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,11 @@ jobs: platform: - os: ubuntu-latest generator: Unix Makefiles + - os: ubuntu-latest + generator: Unix Makefiles + env: + CC: "clang" + CFLAGS: "-fsanitize=leak" - os: macos-latest generator: Unix Makefiles - os: windows-latest @@ -24,6 +29,10 @@ jobs: runs-on: ${{ matrix.platform.os }} + env: + CC: ${{matrix.platform.env.CC}} + CFLAGS: ${{matrix.platform.env.CFLAGS}} + steps: - name: Check out uses: actions/checkout@v2