]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1514: Coverity complains about the use of tmpfile() v9.1.1514
authorChristian Brabandt <cb@256bit.org>
Sun, 6 Jul 2025 08:39:59 +0000 (10:39 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 6 Jul 2025 08:39:59 +0000 (10:39 +0200)
Problem:  coverity complains about the use of tmpfile()
Solution: use vim_tempname() instead to create anonym file

related: #17097
closes: #17674

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/os_unix.c
src/version.c

index 9fd6436e6ff66f6bd06ad513501c62f22622e9ff..c27755f9521258a048460391c7a6cca1c302a3fb 100644 (file)
@@ -8940,13 +8940,24 @@ mch_create_anon_file(void)
        fd = shm_open(template, O_CREAT | O_RDWR | O_EXCL, 0600);
 
        if (fd >= 0 || errno != EEXIST)
-           break; }
+           break;
+    }
     // Remove object name from namespace
     shm_unlink(template);
 #endif
+    // Last resort
     if (fd == -1)
-       // Last resort
-       fd = fileno(tmpfile());
-
+    {
+       char_u  *tempname;
+       // get a name for the temp file
+       if ((tempname = vim_tempname('w', FALSE)) == NULL)
+       {
+           emsg(_(e_cant_get_temp_file_name));
+           return -1;
+       }
+       fd = mch_open((char *)tempname, O_CREAT | O_RDWR | O_EXCL, 0600);
+       mch_remove(tempname);
+       vim_free(tempname);
+    }
     return fd;
 }
index fdf1eb3000556bf54dd74f9e6f69a7b7176d40ed..1cf223d181ab2b52280bb1d46c4960064043b91d 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1514,
 /**/
     1513,
 /**/