Do not forget to allocate internal OPENFILENAMEW structure for 16-bit GetOpenFileName

Dmitry Timoshkov dmitry at baikal.ru
Thu Feb 10 04:45:08 CST 2005


Hello,

this patch fixes a regression for 16-bit applications I introduced with
my recent GetOpenFileName fix for 3.1 style dialogs. It also makes sure
that a freshly allocated ofnW structure is initialized by zeros since
both FD16_MapOfnStruct16 and FD31_MapOfnStructA ignore not initialized
fields of the original structure leaving W version filled with garbage.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Do not forget to allocate internal OPENFILENAMEW structure for
    16-bit GetOpenFileName, initialize it by zeros for 16/A cases.

diff -up cvs/hq/wine/dlls/commdlg/filedlg16.c wine/dlls/commdlg/filedlg16.c
--- cvs/hq/wine/dlls/commdlg/filedlg16.c	2005-02-08 22:21:51.000000000 +0800
+++ wine/dlls/commdlg/filedlg16.c	2005-02-10 18:28:36.000000000 +0800
@@ -170,6 +170,7 @@ static BOOL CALLBACK FD16_Init(LPARAM lP
         if (priv->ofn16->lpfnHook)
             lfs->hook = TRUE;
 
+    lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lfs->ofnW));
     FD16_MapOfnStruct16(priv->ofn16, lfs->ofnW, lfs->open);
 
     if (! FD16_GetTemplate(lfs)) return FALSE;
@@ -280,6 +281,7 @@ static void CALLBACK FD16_Destroy(PFD31_
             GlobalFree16(priv->hGlobal16);
         }
         FD31_FreeOfnW(lfs->ofnW);
+        HeapFree(GetProcessHeap(), 0, lfs->ofnW);
     }
 }
 
diff -up cvs/hq/wine/dlls/commdlg/filedlg.c wine/dlls/commdlg/filedlg.c
--- cvs/hq/wine/dlls/commdlg/filedlg.c	2005-02-08 22:21:51.000000000 +0800
+++ wine/dlls/commdlg/filedlg.c	2005-02-10 18:25:35.000000000 +0800
@@ -3456,7 +3456,7 @@ static BOOL CALLBACK FD32_Init(LPARAM lP
         if (priv->ofnA->Flags & OFN_ENABLEHOOK)
             if (priv->ofnA->lpfnHook)
                 lfs->hook = TRUE;
-        lfs->ofnW = HeapAlloc(GetProcessHeap(), 0, sizeof(*lfs->ofnW));
+        lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lfs->ofnW));
         FD31_MapOfnStructA(priv->ofnA, lfs->ofnW, lfs->open);
     }
 






More information about the wine-patches mailing list