Fix test for invalid handle in w32.c's 'utime'.
authorEli Zaretskii <eliz@gnu.org>
Thu, 4 Oct 2012 20:07:45 +0000 (22:07 +0200)
committerEli Zaretskii <eliz@gnu.org>
Thu, 4 Oct 2012 20:07:45 +0000 (22:07 +0200)
 src/w32.c (utime): Test for INVALID_HANDLE_VALUE, not for NULL, to
 see whether CreateFile failed.

src/ChangeLog
src/w32.c

index 9790ff7..85a4c82 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32.c (utime): Test for INVALID_HANDLE_VALUE, not for NULL, to
+       see whether CreateFile failed.
+
 2012-10-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        * profiler.c (handle_profiler_signal): Inhibit pending signals too,
index 3d3ae7e..6b52fb8 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -3954,7 +3954,7 @@ utime (const char *name, struct utimbuf *times)
   /* Need write access to set times.  */
   fh = CreateFile (name, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
                   0, OPEN_EXISTING, 0, NULL);
-  if (fh)
+  if (fh != INVALID_HANDLE_VALUE)
     {
       convert_from_time_t (times->actime, &atime);
       convert_from_time_t (times->modtime, &mtime);