]> granicus.if.org Git - php/commitdiff
Avoid multiple wcslen() calls
authorAnatol Belski <ab@php.net>
Sun, 18 Feb 2018 19:30:33 +0000 (20:30 +0100)
committerAnatol Belski <ab@php.net>
Sun, 18 Feb 2018 19:30:33 +0000 (20:30 +0100)
win32/ioutil.h

index 8676fd5ac49dade0d5409ff39ebe5919fa2e9a61..cc0f7ac1d3f5af48bc4b236f56c018f8fbbee2f3 100644 (file)
@@ -424,11 +424,14 @@ __forceinline static int php_win32_ioutil_rename(const char *oldnamea, const cha
                free(oldnamew);
                SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
                return -1;
-       } else if (!PHP_WIN32_IOUTIL_PATH_IS_OK_W(newnamew, wcslen(newnamew))) {
-               free(oldnamew);
-               free(newnamew);
-               SET_ERRNO_FROM_WIN32_CODE(ERROR_ACCESS_DENIED);
-               return -1;
+       } else {
+               size_t newnamew_len = wcslen(newnamew);
+               if (!PHP_WIN32_IOUTIL_PATH_IS_OK_W(newnamew, newnamew_len)) {
+                       free(oldnamew);
+                       free(newnamew);
+                       SET_ERRNO_FROM_WIN32_CODE(ERROR_ACCESS_DENIED);
+                       return -1;
+               }
        }
 
        ret = php_win32_ioutil_rename_w(oldnamew, newnamew);