From: juergen.schmied@debitel.net ("Juergen Schmied")
Newsgroups: local.list.wine.patches
Subject: some bugs in filedlg
Date: 15 Nov 1999 21:36:25 +0100
Organization: at home
Lines: 118
Message-ID: <19991115194143.22977.qmail@psmtp1.dnsg.net>
Mime-Version: 1.0
Content-Type: Multipart/Mixed; boundary=Message-Boundary-2348
X-Resent-Date: Mon, 15 Nov 1999 12:41:54 -0700
X-To: wine-patches@winehq.com
X-Reply-to: juergen.schmied@debitel.net
X-Priority: normal
X-Mailer: Pegasus Mail for Win32 (v3.11)
X-Resent-Message-ID: <4zm7fB.A.roD.CIGM4@ursula.gmcl.com>
X-Resent-From: wine-patches@winehq.com
X-Mailing-List: <wine-patches@winehq.com> archive/latest/2128
X-Loop: wine-patches@winehq.com
X-Precedence: list
X-Resent-Sender: wine-patches-request@winehq.com


--Message-Boundary-2348
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

[dlls/commdlg/filedlg95.c]
- the fodInfos were used before initialized
- lpTemplateName can be a resource id
- if lpTemplateName is a string don't free the original one

---
the first one caused a chrash accessing a low memory address, 
the second one a heap error while MemFree and a possible chrash 
when using the unicode version, the third one could possibly cause 
a crash in the app later ...

Happy crashing..... ;-))))

PS: now the "Message Save" of Agent dialog works but look 
strange due to wrong control positions...

juergen
 

---
juergen.schmied@debitel.net

... from sunny Berlin


--Message-Boundary-2348
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file '991115.dif'

Index: dlls/commdlg/filedlg95.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg95.c,v
retrieving revision 1.18
diff -u -r1.18 filedlg95.c
--- wine/dlls/commdlg/filedlg95.c	1999/11/14 21:29:24	1.18
+++ wine/dlls/commdlg/filedlg95.c	1999/11/15 20:10:51
@@ -281,8 +281,14 @@
   fodInfos->ofnInfos.lCustData = ofn->lCustData;
   fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook;
 
-  if (ofn->lpTemplateName)
+  if HIWORD(ofn->lpTemplateName)
   {
+      fodInfos->ofnInfos.lpTemplateName = MemAlloc(strlen(ofn->lpTemplateName)+1);
+      strcpy ((LPSTR)fodInfos->ofnInfos.lpTemplateName, ofn->lpTemplateName);
+  }
+  else
+  {
+      /* resource id */
       fodInfos->ofnInfos.lpTemplateName = ofn->lpTemplateName;
   }
 
@@ -321,7 +327,7 @@
 
   if (fodInfos->ofnInfos.lpstrFilter)
       MemFree((LPVOID)(fodInfos->ofnInfos.lpstrFilter));
-  if (fodInfos->ofnInfos.lpTemplateName)
+  if  HIWORD(fodInfos->ofnInfos.lpTemplateName)
       MemFree((LPVOID)(fodInfos->ofnInfos.lpTemplateName));
   if (fodInfos->ofnInfos.lpstrDefExt)
       MemFree((LPVOID)(fodInfos->ofnInfos.lpstrDefExt));
@@ -441,11 +447,17 @@
   }
   fodInfos->ofnInfos.lCustData = ofn->lCustData;
   fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook;
-  if (ofn->lpTemplateName) 
+
+  if HIWORD(ofn->lpTemplateName) 
   { 
     fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName)+1);
     lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpTemplateName,ofn->lpTemplateName);
   }
+  else
+  {
+      /* resource id */
+      fodInfos->ofnInfos.lpTemplateName = (LPSTR)ofn->lpTemplateName;
+  }
   /* Initialise the dialog property */
   fodInfos->DlgInfos.dwDlgProp = 0;
   
@@ -816,10 +828,14 @@
  */
 HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-
   switch(uMsg)
   {
     case WM_INITDIALOG :
+
+         /* Adds the FileOpenDlgInfos in the property list of the dialog 
+            so it will be easily accessible through a GetPropA(...) */
+      	 SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) lParam);
+
       	 ((FileOpenDlgInfos *)lParam)->DlgInfos.hwndCustomDlg = 
      	CreateTemplateDialog((FileOpenDlgInfos *)lParam,hwnd);
       	 FILEDLG95_OnWMInitDialog(hwnd, wParam, lParam);
@@ -862,10 +878,6 @@
   FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
 
   TRACE("\n");
-
-  /* Adds the FileOpenDlgInfos in the property list of the dialog 
-     so it will be easily accessible through a GetPropA(...) */
-  SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
 
   /* Make sure the common control DLL is loaded */      
   InitCommonControls();

--Message-Boundary-2348--

---
