From aacd6b6593edd777970f00961e510e31bfc8053b Mon Sep 17 00:00:00 2001 From: Tim Wickberg <tim@schedmd.com> Date: Mon, 11 Sep 2017 15:54:24 -0600 Subject: [PATCH] Fix two issues identified by Coverity within the heartbeat code. --- src/slurmctld/heartbeat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/slurmctld/heartbeat.c b/src/slurmctld/heartbeat.c index ed43fb4076c..df23b73befe 100644 --- a/src/slurmctld/heartbeat.c +++ b/src/slurmctld/heartbeat.c @@ -184,11 +184,12 @@ time_t get_last_heartbeat(void) * at the moment. Once opened, our handle should persist during * the shuffle, as the contents are left intact. */ - for (i = 0; i < OPEN_RETRIES; i++) { + for (i = 0; (i < OPEN_RETRIES) && (fd < 0); i++) { fd = open(file, O_RDONLY); if (fd < 0) { error("%s: heartbeat open attempt %d failed from %s.", __func__, i, file); + xfree(file); return 0; } } @@ -200,6 +201,7 @@ time_t get_last_heartbeat(void) } close(fd); + xfree(file); return (time_t) NTOH_uint64(value); } -- GitLab