]> granicus.if.org Git - php/commitdiff
Revert "Improve conversion loop"
authorAnatol Belski <ab@php.net>
Mon, 12 Feb 2018 21:57:32 +0000 (22:57 +0100)
committerAnatol Belski <ab@php.net>
Mon, 12 Feb 2018 21:59:21 +0000 (22:59 +0100)
This reverts commit 7a4573a55ad244b66c40b4086e432775b6f185b7.

Don't read over '\0'.

win32/ioutil.h

index c413b78b2a22f06f200adb341cad4994175ae6f0..41773b306ec3b8fa8cede449a975fe56e9fb81a2 100644 (file)
@@ -376,7 +376,7 @@ __forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const char
 {/*{{{*/
        FILE *ret;
        wchar_t modew[16] = {0};
-       int err = 0, i;
+       int err = 0, i = 0;
 
        PHP_WIN32_IOUTIL_INIT_W(patha)
        if (!pathw) {
@@ -386,8 +386,9 @@ __forceinline static FILE *php_win32_ioutil_fopen(const char *patha, const char
 
        PHP_WIN32_IOUTIL_CHECK_PATH_W(pathw, NULL, 1)
 
-       for (i = 0; i < (sizeof(modew)-1)/sizeof(wchar_t); i++) {
+       while (i < (sizeof(modew)-1)/sizeof(wchar_t) && modea[i]) {
                modew[i] = (wchar_t)modea[i];
+               i++;
        }
 
        ret = php_win32_ioutil_fopen_w(pathw, modew);