Nikolay Sivov : comdlg32: Take nMaxFile into account when converting A->W.

Alexandre Julliard julliard at winehq.org
Mon Mar 13 15:40:32 CDT 2017


Module: wine
Branch: master
Commit: a44a6083784e6b78ef636e73548321cef06b381a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a44a6083784e6b78ef636e73548321cef06b381a

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sun Mar 12 21:18:40 2017 +0300

comdlg32: Take nMaxFile into account when converting A->W.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comdlg32/filedlg.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 0c9f34a..305ac62 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -383,18 +383,26 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
 static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
 {
     OPENFILENAMEW ofnW;
+    int len;
 
     ofnW = *(OPENFILENAMEW *)ofn;
 
     ofnW.lpstrInitialDir = heap_strdupAtoW(ofn->lpstrInitialDir);
-    ofnW.lpstrFile = heap_strdupAtoW(ofn->lpstrFile);
     ofnW.lpstrDefExt = heap_strdupAtoW(ofn->lpstrDefExt);
     ofnW.lpstrTitle = heap_strdupAtoW(ofn->lpstrTitle);
 
+    if (ofn->lpstrFile)
+    {
+        len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0);
+        ofnW.lpstrFile = MemAlloc(len * sizeof(WCHAR));
+        MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len);
+        ofnW.nMaxFile = len;
+    }
+
     if (ofn->lpstrFilter)
     {
-        int n, len;
         LPCSTR s;
+        int n;
 
         /* filter is a list...  title\0ext\0......\0\0 */
         s = ofn->lpstrFilter;




More information about the wine-cvs mailing list