diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index ba3049c53..1ce7b5207 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -252,7 +252,8 @@ std::string make_temp_dir(std::string template_str)
 	log_assert(suffixlen == 0);
 
 	char *p = strdup(template_str.c_str());
-	mkdtemp(p);
+	p = mkdtemp(p);
+	log_assert(p != NULL);
 	template_str = p;
 	free(p);