]> granicus.if.org Git - nethack/commitdiff
follow-up bit; ensure the mkstemp() file is unlinked
authornhmall <nhmall@nethack.org>
Tue, 22 Sep 2020 14:11:51 +0000 (10:11 -0400)
committernhmall <nhmall@nethack.org>
Tue, 22 Sep 2020 14:11:51 +0000 (10:11 -0400)
util/makedefs.c

index 0cf4b09e31d73031af276d13b7ec027d72b25e6b..147164fdeaeadab6284fb26523faf14c5ec05ed8 100644 (file)
@@ -416,8 +416,10 @@ int flg UNUSED;
     if (istemp) {
         (void) snprintf(tmpfbuf, sizeof tmpfbuf, DATA_TEMPLATE, "mdXXXXXX");
         tmpfd = mkstemp(tmpfbuf);
-        if (tmpfd >= 0)
+        if (tmpfd >= 0) {
             rv = fdopen(tmpfd, WRTMODE);   /* temp file is always read+write */
+            Unlink(tmpfbuf);
+       }
     } else
 #endif
     rv = fopen(name, mode);