From 7234b8f13abf9e72dfe1ea3dfe4e4bbee4f34902 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Fri, 11 Sep 2015 09:59:57 -0700 Subject: [PATCH] slurmctld/nonstop: plug memory leak on error on allocation failure, prevent skipping over xfree of strings. --- src/plugins/slurmctld/nonstop/do_work.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/plugins/slurmctld/nonstop/do_work.c b/src/plugins/slurmctld/nonstop/do_work.c index 42b55b1bc90..529d95100bf 100644 --- a/src/plugins/slurmctld/nonstop/do_work.c +++ b/src/plugins/slurmctld/nonstop/do_work.c @@ -1345,6 +1345,16 @@ extern char *replace_node(char *cmd_ptr, uid_t cmd_uid, if (i == SLURM_SUCCESS) will_run_time = will_run_idle; } + xfree(job_alloc_req.account); + xfree(job_alloc_req.dependency); + xfree(job_alloc_req.exc_nodes); + xfree(job_alloc_req.features); + xfree(job_alloc_req.gres); + xfree(job_alloc_req.name); + xfree(job_alloc_req.network); + xfree(job_alloc_req.partition); + xfree(job_alloc_req.qos); + xfree(job_alloc_req.wckey); pthread_mutex_lock(&job_fail_mutex); /* Resume lock */ @@ -1375,18 +1385,6 @@ extern char *replace_node(char *cmd_ptr, uid_t cmd_uid, goto fini; } - xfree(job_alloc_req.account); - xfree(job_alloc_req.dependency); - xfree(job_alloc_req.exc_nodes); - xfree(job_alloc_req.features); - xfree(job_alloc_req.gres); - xfree(job_alloc_req.name); - xfree(job_alloc_req.network); - xfree(job_alloc_req.partition); - xfree(job_alloc_req.qos); - xfree(job_alloc_req.reservation); - xfree(job_alloc_req.wckey); - merge: if (!new_job_ptr) { /* Fix for CLANG false positive */ error("%s: New job is NULL", __func__); -- GitLab