@@ -246,7 +246,9 @@ __forceinline static int php_win32_ioutil_access(const char *path, mode_t mode)
246
246
PHP_WIN32_IOUTIL_CHECK_PATH_W (pathw , -1 , 1 )
247
247
248
248
ret = _waccess (pathw , mode );
249
- _get_errno (& err );
249
+ if (0 > ret ) {
250
+ _get_errno (& err );
251
+ }
250
252
PHP_WIN32_IOUTIL_CLEANUP_W ()
251
253
252
254
if (0 > ret ) {
@@ -279,7 +281,9 @@ __forceinline static int php_win32_ioutil_open(const char *path, int flags, ...)
279
281
}
280
282
281
283
ret = php_win32_ioutil_open_w (pathw , flags , mode );
282
- err = GetLastError ();
284
+ if (0 > ret ) {
285
+ err = GetLastError ();
286
+ }
283
287
PHP_WIN32_IOUTIL_CLEANUP_W ()
284
288
285
289
if (0 > ret ) {
@@ -368,7 +372,9 @@ __forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const char
368
372
}
369
373
370
374
ret = _wfopen (pathw , modew );
371
- _get_errno (& err );
375
+ if (!ret ) {
376
+ _get_errno (& err );
377
+ }
372
378
free (pathw );
373
379
free (modew );
374
380
@@ -405,7 +411,9 @@ __forceinline static int php_win32_ioutil_rename(const char *oldnamea, const cha
405
411
}
406
412
407
413
ret = php_win32_ioutil_rename_w (oldnamew , newnamew );
408
- err = GetLastError ();
414
+ if (0 > ret ) {
415
+ err = GetLastError ();
416
+ }
409
417
410
418
free (oldnamew );
411
419
free (newnamew );
@@ -429,7 +437,9 @@ __forceinline static int php_win32_ioutil_chdir(const char *patha)
429
437
}
430
438
431
439
ret = php_win32_ioutil_chdir_w (pathw );
432
- err = GetLastError ();
440
+ if (0 > ret ) {
441
+ err = GetLastError ();
442
+ }
433
443
434
444
free (pathw );
435
445
@@ -495,7 +505,9 @@ __forceinline static int php_win32_ioutil_chmod(const char *patha, int mode)
495
505
PHP_WIN32_IOUTIL_CHECK_PATH_W (pathw , -1 , 1 )
496
506
497
507
ret = _wchmod (pathw , mode );
498
- _get_errno (& err );
508
+ if (0 > ret ) {
509
+ _get_errno (& err );
510
+ }
499
511
500
512
free (pathw );
501
513
0 commit comments