diff --git a/src/slurmctld/heartbeat.c b/src/slurmctld/heartbeat.c index ed43fb4076c393601a15a54098dec624f7ea2099..df23b73befe3da57c07d19eb73eed45d8ac44079 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); }