From c0992ada323c94517800163a72ccea9519ffcc3c Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 10 Nov 2005 18:45:59 +0000
Subject: [PATCH] free fix for ctx deletion

---
 src/api/spawn.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/api/spawn.c b/src/api/spawn.c
index 05eca7864e1..51d958341bd 100644
--- a/src/api/spawn.c
+++ b/src/api/spawn.c
@@ -323,8 +323,10 @@ slurm_step_ctx_destroy (slurm_step_ctx ctx)
 	step_layout_destroy(ctx->step_layout);
 	slurm_free_job_step_create_response_msg(ctx->step_resp);
 	slurm_free_resource_allocation_response_msg(ctx->alloc_resp);
-	_xfree_char_array(&ctx->argv, ctx->argc);
-	_xfree_char_array(&ctx->env, ctx->envc);
+	if (ctx->argv)
+		_xfree_char_array(&ctx->argv, ctx->argc);
+	if (ctx->env_set)
+		_xfree_char_array(&ctx->env, ctx->envc);
 	xfree(ctx->cwd);
 	xfree(ctx);
 	return SLURM_SUCCESS;
@@ -760,7 +762,6 @@ static void _xfree_char_array(char ***argv_p, int cnt)
 {
 	char **argv = *argv_p;
 	int i;
-
 	for (i=0; i<cnt; i++)
 		xfree(argv[i]);
 	xfree(*argv_p);
-- 
GitLab