diff --git a/NEWS b/NEWS
index 558946a7e95694c02fae6dbafda82f912ac61b2e..11c500ccc79fb6405f91aa14b9786308b658eb1a 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ documents those changes that are of interest to users and admins.
     the slurmdbd.
  -- Fix bug in changing the nodes allocated to a running job and some node
     names specified are invalid, avoid invalid memory reference.
+ -- Fixed bug in slurmd.c based on patch from Ralph Bean
 
 * Changes in SLURM 2.2.0.pre9
 =============================
diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c
index c1a4da883c3cc78081b569597df03b6a0783870b..dff629add2ae28137ee9d21311dc3a7b6b03a4cc 100644
--- a/src/slurmd/slurmd/slurmd.c
+++ b/src/slurmd/slurmd/slurmd.c
@@ -675,20 +675,19 @@ _free_and_set(char **confvar, char *newval)
 	*confvar = newval;
 }
 
-/* Replace first "%h" in path string with actual hostname.
+/*
+ * Replace first "%h" in path string with actual hostname.
  * Replace first "%n" in path string with NodeName.
- *
- * Make sure to call _massage_pathname AFTER conf->node_name has been
- * fully initialized.
  */
 static void
 _massage_pathname(char **path)
 {
-	if (conf->logfile == NULL)
-		return;
-
-	xstrsubstitute(*path, "%h", conf->hostname);
-	xstrsubstitute(*path, "%n", conf->node_name);
+	if (path && *path) {
+		if (conf->hostname)
+			xstrsubstitute(*path, "%h", conf->hostname);
+		if (conf->node_name)
+			xstrsubstitute(*path, "%n", conf->node_name);
+	}
 }
 
 /*