Windows: don't set create time for invalid/stream fd (#2571)

This commit is contained in:
Lovell Fuller 2021-12-06 13:52:02 +00:00 committed by GitHub
parent e0bb8e5d58
commit b28ee777ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -586,6 +586,12 @@ vips__set_create_time( int fd )
SYSTEMTIME st;
FILETIME ft;
/* Create time cannot be set on invalid or stream
* (stdin, stdout, stderr) file descriptors.
*/
if( fd < 3 )
return;
if( (handle = (HANDLE) _get_osfhandle( fd )) == INVALID_HANDLE_VALUE )
return;
GetSystemTime( &st );
@ -635,7 +641,7 @@ vips__fopen( const char *filename, const char *mode )
fp = g_fopen( filename, mode );
#ifdef G_OS_WIN32
if( mode[0] == 'w' )
if( fp && mode[0] == 'w' )
vips__set_create_time( _fileno( fp ) );
#endif /*G_OS_WIN32*/