FILEDLG_MapOfnStructA bug?
Francois Gouget
fgouget at free.fr
Sat Apr 24 06:08:05 CDT 2004
Looking at the FILEDLG_MapOfnStructA code the following lines are very
suspicious:
970: if (ofnA->lpstrTitle)
971: str = ofnA->lpstrTitle;
972: else
973: /* Allocates default title (FIXME : get it from resource) */
974: str = open ? defaultopen:defaultsave;
975: RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrTitle);
...
So if ofnA->lpstrTitle is NULL we set str to point to something
non-NULL. However str is never used. Even more suspicious, right after
this check we use ofnA->lpstrTitle eventhough it might be NULL.
Looking into the CVS history I found that we used to use str when
setting up ofnW->lpstrTitle. This was changed by this patch (that code
was in filedlg.c at the time):
dlls/commdlg/filedlg.c
revision 1.59
date: 2003/01/23 23:07:39; author: julliard; state: Exp; lines: +12 -3
Matthew Davison <m.davison at virgin.net>
Removed calls to HEAP_strdupAtoW.
So here's a patch that should make things more like they were supposed
to be. Hmmm, what if the application makes a Unicode call with
a NULL lpstrTitle? Shouldn't we set it to 'Open File' or 'Save
as' too?
Changelog:
* dlls/commdlg/filedlg16.c
If lpstrTitle is NULL, set it to either 'Open File' or 'Save as'.
Constify the string constants.
Index: dlls/commdlg/filedlg16.c
===================================================================
RCS file: /var/cvs/wine/dlls/commdlg/filedlg16.c,v
retrieving revision 1.9
diff -u -r1.9 filedlg16.c
--- a/dlls/commdlg/filedlg16.c 12 Apr 2004 22:03:55 -0000 1.9
+++ b/dlls/commdlg/filedlg16.c 20 Apr 2004 18:06:13 -0000
@@ -84,8 +84,6 @@
static HICON hHDisk = 0;
static HICON hCDRom = 0;
static HICON hNet = 0;
-static char defaultopen[]="Open File";
-static char defaultsave[]="Save as";
/***********************************************************************
* FileDlg_Init [internal]
@@ -970,9 +968,13 @@
if (ofnA->lpstrTitle)
str = ofnA->lpstrTitle;
else
+ {
/* Allocates default title (FIXME : get it from resource) */
+ static const char* defaultopen="Open File";
+ static const char* defaultsave="Save as";
str = open ? defaultopen:defaultsave;
- RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrTitle);
+ }
+ RtlCreateUnicodeStringFromAsciiz (&usBuffer,str);
ofnW->lpstrTitle = usBuffer.Buffer;
ofnW->Flags = ofnA->Flags;
ofnW->nFileOffset = ofnA->nFileOffset;
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
"Lotto: A tax on people who are bad at math." -- unknown
"Windows: Microsoft's tax on computer illiterates." -- WE7U
More information about the wine-patches
mailing list