diff --git a/src/common/stepd_api.c b/src/common/stepd_api.c index ee5b8ac9344e2afb86b91fdd274ba1a947074d18..a0bc4e8644240594f03cc72e6955b1682cf01629 100644 --- a/src/common/stepd_api.c +++ b/src/common/stepd_api.c @@ -979,7 +979,7 @@ stepd_list_pids(int fd, uint32_t **pids_array, uint32_t *pids_count) { int req = REQUEST_STEP_LIST_PIDS; uint32_t npids; - uint32_t *pids; + uint32_t *pids = NULL; int i; safe_write(fd, &req, sizeof(int)); @@ -991,16 +991,15 @@ stepd_list_pids(int fd, uint32_t **pids_array, uint32_t *pids_count) safe_read(fd, &pids[i], sizeof(uint32_t)); } - if (npids == 0) { - *pids_count = 0; - *pids_array = NULL; - } else { - *pids_count = npids; - *pids_array = pids; - } + if (npids == 0) + xfree(pids); + *pids_count = npids; + *pids_array = pids; return SLURM_SUCCESS; + rwfail: + xfree(pids); *pids_count = 0; *pids_array = NULL; return SLURM_ERROR;