From a897adba3b034234f9ed8d1759f63b78f0ce5023 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 09:32:21 -0500 Subject: Free members recently added to Delivery structure --- src/lib/delivery/delivery.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/lib/delivery/delivery.c b/src/lib/delivery/delivery.c index aa3e51a..ad947f3 100644 --- a/src/lib/delivery/delivery.c +++ b/src/lib/delivery/delivery.c @@ -50,8 +50,10 @@ void delivery_free(struct Delivery *ctx) { guard_free(ctx->conda.tool_build_version); guard_strlist_free(&ctx->conda.conda_packages); guard_strlist_free(&ctx->conda.conda_packages_defer); + guard_strlist_free(&ctx->conda.conda_packages_purge); guard_strlist_free(&ctx->conda.pip_packages); guard_strlist_free(&ctx->conda.pip_packages_defer); + guard_strlist_free(&ctx->conda.pip_packages_purge); guard_strlist_free(&ctx->conda.wheels_packages); for (size_t i = 0; i < sizeof(ctx->tests) / sizeof(ctx->tests[0]); i++) { @@ -62,6 +64,7 @@ void delivery_free(struct Delivery *ctx) { guard_free(ctx->tests[i].repository_info_tag); guard_strlist_free(&ctx->tests[i].repository_remove_tags); guard_free(ctx->tests[i].script); + guard_free(ctx->tests[i].script_setup); guard_free(ctx->tests[i].build_recipe); // test-specific runtime variables guard_runtime_free(ctx->tests[i].runtime.environ); -- cgit From 672cdfa07cf83fec396836cbe1ba1415e5764ebf Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 09:33:18 -0500 Subject: Improve message on memory error --- src/lib/delivery/delivery_populate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/delivery/delivery_populate.c b/src/lib/delivery/delivery_populate.c index e9aea89..f14016a 100644 --- a/src/lib/delivery/delivery_populate.c +++ b/src/lib/delivery/delivery_populate.c @@ -34,7 +34,7 @@ int populate_info(struct Delivery *ctx) { ctx->info.time_str_epoch = calloc(STASIS_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch)); if (!ctx->info.time_str_epoch) { - msg(STASIS_MSG_ERROR, "Unable to allocate memory for Unix epoch string\n"); + msg(STASIS_MSG_ERROR, "%s: Unable to allocate memory for Unix epoch string\n", strerror(errno)); return -1; } snprintf(ctx->info.time_str_epoch, STASIS_TIME_STR_MAX - 1, "%li", ctx->info.time_now); -- cgit From 78ded5bc427eba89e425064e38b63dd65a4c679b Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 09:36:14 -0500 Subject: Replace localtime with localtime_r and allocate a new buffer for each Delivery context --- src/lib/delivery/delivery.c | 1 + src/lib/delivery/delivery_init.c | 8 +++++--- src/lib/delivery/delivery_populate.c | 12 +++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/delivery/delivery.c b/src/lib/delivery/delivery.c index ad947f3..41be64c 100644 --- a/src/lib/delivery/delivery.c +++ b/src/lib/delivery/delivery.c @@ -40,6 +40,7 @@ void delivery_free(struct Delivery *ctx) { guard_free(ctx->info.build_name); guard_free(ctx->info.build_number); guard_free(ctx->info.release_name); + guard_free(ctx->info.time_info); guard_free(ctx->conda.installer_baseurl); guard_free(ctx->conda.installer_name); guard_free(ctx->conda.installer_version); diff --git a/src/lib/delivery/delivery_init.c b/src/lib/delivery/delivery_init.c index 2fced03..fe60075 100644 --- a/src/lib/delivery/delivery_init.c +++ b/src/lib/delivery/delivery_init.c @@ -296,10 +296,12 @@ int bootstrap_build_info(struct Delivery *ctx) { ctx->info.build_name = strdup(local.info.build_name); ctx->info.build_number = strdup(local.info.build_number); ctx->info.release_name = strdup(local.info.release_name); - ctx->info.time_info = malloc(sizeof(*ctx->info.time_info)); if (!ctx->info.time_info) { - SYSERROR("Unable to allocate %zu bytes for tm struct: %s", sizeof(*local.info.time_info), strerror(errno)); - return -1; + ctx->info.time_info = malloc(sizeof(*ctx->info.time_info)); + if (!ctx->info.time_info) { + SYSERROR("Unable to allocate %zu bytes for tm struct: %s", sizeof(*local.info.time_info), strerror(errno)); + return -1; + } } memcpy(ctx->info.time_info, local.info.time_info, sizeof(*local.info.time_info)); ctx->info.time_now = local.info.time_now; diff --git a/src/lib/delivery/delivery_populate.c b/src/lib/delivery/delivery_populate.c index f14016a..63df9fd 100644 --- a/src/lib/delivery/delivery_populate.c +++ b/src/lib/delivery/delivery_populate.c @@ -30,7 +30,17 @@ int populate_info(struct Delivery *ctx) { if (!ctx->info.time_str_epoch) { // Record timestamp used for release time(&ctx->info.time_now); - ctx->info.time_info = localtime(&ctx->info.time_now); + if (!ctx->info.time_info) { + ctx->info.time_info = malloc(sizeof(*ctx->info.time_info)); + if (!ctx->info.time_info) { + msg(STASIS_MSG_ERROR, "%s: Unable to allocate memory for time_info\n", strerror(errno)); + return -1; + } + if (!localtime_r(&ctx->info.time_now, ctx->info.time_info)) { + msg(STASIS_MSG_ERROR, "%s: localtime_r failed\n", strerror(errno)); + return -1; + } + } ctx->info.time_str_epoch = calloc(STASIS_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch)); if (!ctx->info.time_str_epoch) { -- cgit From b67ad320163238989047779a37ba973d8fd46ed5 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 10:57:00 -0500 Subject: Free wheel platform tag --- src/lib/core/wheel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/lib/core/wheel.c b/src/lib/core/wheel.c index d5d5ff0..32091cd 100644 --- a/src/lib/core/wheel.c +++ b/src/lib/core/wheel.c @@ -121,5 +121,6 @@ void wheel_free(struct Wheel **wheel) { guard_free(w->python_tag); guard_free(w->abi_tag); guard_free(w->python_tag); + guard_free(w->platform_tag); guard_free(w); } -- cgit From 1b6af714a5d6cb5d7af2f19412c1418a8b02c4d4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 10:58:51 -0500 Subject: junitxml: free _Error struct --- src/lib/core/junitxml.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/lib/core/junitxml.c b/src/lib/core/junitxml.c index f747224..9e07c5c 100644 --- a/src/lib/core/junitxml.c +++ b/src/lib/core/junitxml.c @@ -8,6 +8,9 @@ static void testcase_result_state_free(struct JUNIT_Testcase **testcase) { if (tc->tc_result_state_type == JUNIT_RESULT_STATE_FAILURE) { guard_free(tc->result_state.failure->message); guard_free(tc->result_state.failure); + } else if (tc->tc_result_state_type == JUNIT_RESULT_STATE_ERROR) { + guard_free(tc->result_state.error->message); + guard_free(tc->result_state.error); } else if (tc->tc_result_state_type == JUNIT_RESULT_STATE_SKIPPED) { guard_free(tc->result_state.skipped->message); guard_free(tc->result_state.skipped); -- cgit From c8185e5c6cd12ee43737fd1c3de84d4231a4c52c Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 10:59:03 -0500 Subject: junitxml: free pointer to testcase array --- src/lib/core/junitxml.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/lib/core/junitxml.c b/src/lib/core/junitxml.c index 9e07c5c..628f75f 100644 --- a/src/lib/core/junitxml.c +++ b/src/lib/core/junitxml.c @@ -34,6 +34,7 @@ void junitxml_testsuite_free(struct JUNIT_Testsuite **testsuite) { for (size_t i = 0; i < suite->_tc_alloc; i++) { testcase_free(&suite->testcase[i]); } + guard_free(suite->testcase); guard_free(suite); } -- cgit From e8811a2936245718cfe2a833999508dc2a1bf6fc Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 4 Feb 2025 11:43:27 -0500 Subject: trlist_remove: free the requested index before moving the pointers up --- src/lib/core/strlist.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/lib/core/strlist.c b/src/lib/core/strlist.c index ec7b3f4..0436f54 100644 --- a/src/lib/core/strlist.c +++ b/src/lib/core/strlist.c @@ -218,6 +218,7 @@ void strlist_remove(struct StrList *pStrList, size_t index) { return; } if (pStrList->data[index] != NULL) { + guard_free(pStrList->data[index]); for (size_t i = index; i < count; i++) { pStrList->data[i] = pStrList->data[i + 1]; } -- cgit