From d1642b3514f23be90e8292fce4569990c813d8eb Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 30 Sep 2024 11:54:34 -0400 Subject: Fix leaking of basetemp_path and jxml_path on error * Reported by @kmacdonald-stsci --- src/template_func_proto.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/template_func_proto.c b/src/template_func_proto.c index 9f1283f..9c325bb 100644 --- a/src/template_func_proto.c +++ b/src/template_func_proto.c @@ -137,12 +137,15 @@ int tox_run_entrypoint(void *frame, void *data_out) { } char *jxml_path = NULL; if (get_junitxml_file_entrypoint(f, &jxml_path)) { + guard_free(basetemp_path); return -3; } const char *tox_target = f->argv[0].t_char_ptr; const char *pytest_args = f->argv[1].t_char_ptr; if (isempty(toxconf) || !strcmp(toxconf, "/")) { SYSERROR("Unsafe toxconf path: '%s'", toxconf); + guard_free(basetemp_path); + guard_free(jxml_path); return -4; } snprintf(*output, STASIS_BUFSIZ - 1, "\npip install tox && (tox -e py%s%s -c %s --root . -- --basetemp=\"%s\" --junitxml=\"%s\" %s ; rm -f '%s')\n", ctx->meta.python_compact, tox_target, toxconf, basetemp_path, jxml_path, pytest_args ? pytest_args : "", toxconf); -- cgit