Bruno Jesus : comdlg32: Avoid crash when a path is passed into Open File Dialog.

Alexandre Julliard julliard at winehq.org
Mon Dec 19 13:10:38 CST 2016


Module: wine
Branch: stable
Commit: 673bafaa7ad5c7c9f8b380739fb3601085a2a044
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=673bafaa7ad5c7c9f8b380739fb3601085a2a044

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Thu Oct 27 06:53:27 2016 +0000

comdlg32: Avoid crash when a path is passed into Open File Dialog.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 58091188929f9786b408912c991420f54f489f6a)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

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

diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 1453396..1b9ad43 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -1564,10 +1564,16 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
          result = GetFullPathNameW(fodInfos->filename, MAX_PATH, tmpBuf, &nameBit);
          if (result) {
 
-            /* nameBit is always shorter than the original filename */
-            lstrcpyW(fodInfos->filename,nameBit);
+            /* nameBit is always shorter than the original filename. It may be NULL
+             * when the filename contains only a drive name instead of file name */
+            if (nameBit)
+            {
+                lstrcpyW(fodInfos->filename,nameBit);
+                *nameBit = 0x00;
+            }
+            else
+                *fodInfos->filename = '\0';
 
-            *nameBit = 0x00;
             MemFree(fodInfos->initdir);
             fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
             lstrcpyW(fodInfos->initdir, tmpBuf);




More information about the wine-cvs mailing list