Commit e1e77cc43b61294facdf656a456a4108c13eb638

Stefan Sperling 2020-03-17T15:49:17

in got_opentempfd() don't attempt to unlink the file if mkstemp(3) failed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/lib/opentemp.c b/lib/opentemp.c
index 9bc6f86..e998f5b 100644
--- a/lib/opentemp.c
+++ b/lib/opentemp.c
@@ -34,7 +34,8 @@ got_opentempfd(void)
 		return -1;
 
 	fd = mkstemp(name);
-	unlink(name);
+	if (fd != -1)
+		unlink(name);
 	return fd;
 }