]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix tempfile bug on platforms lacking mkostemp and mkstemp.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Jul 2013 21:44:43 +0000 (23:44 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Jul 2013 21:44:43 +0000 (23:44 +0200)
* callproc.c (create_temp_file) [! (HAVE_MKOSTEMP || HAVE_MKSTEMP)]:
Do not assume that emacs_close (INT_MAX) is a no-op.

Fixes: debbugs:14986
src/ChangeLog
src/callproc.c

index bfe4dfaf39a1edfe0f48905a3bbab805fb938f52..fd54607049eaa67d3439b432f8019973cc8057cb 100644 (file)
@@ -1,3 +1,9 @@
+2013-07-30  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix tempfile bug on platforms lacking mkostemp and mkstemp (Bug#14986).
+       * callproc.c (create_temp_file) [! (HAVE_MKOSTEMP || HAVE_MKSTEMP)]:
+       Do not assume that emacs_close (INT_MAX) is a no-op.
+
 2013-07-30  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * xfaces.c (make_face_cache): For struct face_cache, prefer
index 91f29bd589b4ba1d2d0b38c70b29fc14895ce622..450fc57f9298f4fed7ff8c6a728e6d9a40115051 100644 (file)
@@ -1018,13 +1018,14 @@ create_temp_file (ptrdiff_t nargs, Lisp_Object *args)
 #else
       errno = EEXIST;
       mktemp (tempfile);
-      /* INT_MAX denotes success, because close (INT_MAX) does nothing.  */
-      fd = *tempfile ? INT_MAX : -1;
+      fd = *tempfile ? 0 : -1;
 #endif
       if (fd < 0)
        report_file_error ("Failed to open temporary file using pattern",
                           pattern);
+#if defined HAVE_MKOSTEMP || defined HAVE_MKSTEMP
       emacs_close (fd);
+#endif
     }
 
     record_unwind_protect (delete_temp_file, filename_string);