From 10561dd776725fae3d775c4e0e7bc069eeb7ccbb Mon Sep 17 00:00:00 2001 From: Dominik Bartkiewicz <bart@schedmd.com> Date: Mon, 20 Jun 2016 14:20:27 +0200 Subject: [PATCH] fix CID 45093 Resource leak --- src/srun/libsrun/srun_job.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/srun/libsrun/srun_job.c b/src/srun/libsrun/srun_job.c index 912b79bff42..89add7a1f23 100644 --- a/src/srun/libsrun/srun_job.c +++ b/src/srun/libsrun/srun_job.c @@ -277,9 +277,10 @@ job_step_create_allocation(resource_allocation_response_msg_t *resp) buf = hostlist_ranged_string_xmalloc(inc_hl); hostlist_delete(tmp_hl, buf); xfree(buf); - while ((node_name = hostlist_shift(tmp_hl)) && - (i < diff)) { + while ((i < diff) && + (node_name = hostlist_shift(tmp_hl))) { hostlist_push_host(inc_hl, node_name); + free(node_name); i++; } hostlist_destroy(tmp_hl); -- GitLab