diff --git a/src/slurmd/mgr.c b/src/slurmd/mgr.c index c356a39cfa28533965a3bb4ff79947718613cf04..1f266e3e17312e2a530f4d4d09eaa75defcfbcea 100644 --- a/src/slurmd/mgr.c +++ b/src/slurmd/mgr.c @@ -264,8 +264,7 @@ mgr_launch_batch_job(batch_job_launch_msg_t *msg, slurm_addr *cli) if ((batchdir = _make_batch_dir(job)) == NULL) goto cleanup2; - if (job->argv[0]) - xfree(job->argv[0]); + FREE_NULL(job->argv[0]); if ((job->argv[0] = _make_batch_script(msg, batchdir)) == NULL) goto cleanup3; diff --git a/src/slurmd/req.c b/src/slurmd/req.c index 8a6c8fb0dd6c7fc7ede44f1bae20cd5c09a68d54..a3bbb18953f8fdef789c157698b797edaa420109 100644 --- a/src/slurmd/req.c +++ b/src/slurmd/req.c @@ -421,6 +421,7 @@ _rpc_reattach_tasks(slurm_msg_t *msg, slurm_addr *cli) reattach_tasks_request_msg_t *req = msg->data; reattach_tasks_response_msg_t resp; + memset(&resp, 0, sizeof(reattach_tasks_response_msg_t)); slurm_get_addr(cli, &port, host, sizeof(host)); req_uid = slurm_auth_uid(msg->cred); req_gid = slurm_auth_gid(msg->cred); @@ -483,8 +484,8 @@ _rpc_reattach_tasks(slurm_msg_t *msg, slurm_addr *cli) slurm_send_only_node_msg(&resp_msg); - xfree(resp.gids); - xfree(resp.local_pids); + FREE_NULL(resp.gids); + FREE_NULL(resp.local_pids); } diff --git a/src/slurmd/shm.c b/src/slurmd/shm.c index 5034ede844a69050a4c487a940aea483c8225648..500640f6e02869c81411beef97d5dd96eacb5327 100644 --- a/src/slurmd/shm.c +++ b/src/slurmd/shm.c @@ -429,7 +429,7 @@ _shm_copy_step(job_step_t *j) job_step_t *s; task_t *t; - s = xmalloc(sizeof(*s)); + s = xmalloc(sizeof(job_step_t)); _shm_step_copy(s, j); for (t = _taskp(j->task_list); t; t = _taskp(t->next)) { @@ -761,7 +761,7 @@ static void _shm_task_copy(task_t *to, task_t *from) { *to = *from; - /* next and step are not valid for copying */ + /* next and job_step are not valid for copying */ to->used = 1; to->next = NULL; to->job_step = NULL; diff --git a/src/slurmd/slurmd.h b/src/slurmd/slurmd.h index 9b9700bfbd8a2354d881fe7d671ddf7e413d7487..0a87f054ef1582d4311af5ccf9db9d4a31dc4993 100644 --- a/src/slurmd/slurmd.h +++ b/src/slurmd/slurmd.h @@ -50,6 +50,14 @@ #ifndef __USE_XOPEN_EXTENDED extern pid_t getsid(pid_t pid); /* missing from <unistd.h> */ #endif + +#define FREE_NULL(_X) \ + do { \ + if (_X) xfree (_X); \ + _X = NULL; \ + } while (0) + + /* * Global config type */