From 213195c4dbfc0dc72276a2bc260c89125a212ddc Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 24 Jun 2022 13:38:35 +0100 Subject: [PATCH] tests: Don't leak args when skipping tests We treat the argv we pass into the compositor as its to mangle, just as it is free to do so for POSIX argv. To support this, we stash argv away and free the saved copy later so as to not leak. This works perfectly, except when we never call the compositor at all, and have no saved array to free. Make sure we free the args in this case, which can be seen as a leak of any generated args when a test skips on preflight checks, e.g. drm-smoke when not running in CI. Signed-off-by: Daniel Stone --- tests/weston-test-fixture-compositor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/weston-test-fixture-compositor.c b/tests/weston-test-fixture-compositor.c index 420ab8f1..228bb48e 100644 --- a/tests/weston-test-fixture-compositor.c +++ b/tests/weston-test-fixture-compositor.c @@ -93,6 +93,11 @@ prog_args_fini(struct prog_args *p) { int i; + /* If our args have never been saved, then we haven't called the + * compositor, but we still need to free the args, not leak them. */ + if (!p->saved) + prog_args_save(p); + if (p->saved) { for (i = 0; i < p->argc; i++) free(p->saved[i]);