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