Avoid crashes when ofnW->lpstrFile is null.
diff --git a/dlls/commdlg/filedlg.c b/dlls/commdlg/filedlg.c
index 5d60940..3162a61 100644
--- a/dlls/commdlg/filedlg.c
+++ b/dlls/commdlg/filedlg.c
@@ -669,8 +669,8 @@
LPOPENFILENAME16 ofn16 = lfs->ofn16;
char *dest = MapSL(ofn16->lpstrFile);
if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
- tmp, ofnW->nMaxFile, NULL, NULL ))
- tmp[ofnW->nMaxFile-1] = 0;
+ tmp, sizeof(tmp), NULL, NULL ))
+ tmp[sizeof(tmp)-1] = 0;
GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
/* the same procedure as every year... */
@@ -685,7 +685,8 @@
}
if (lfs->ofnA)
{
- if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
+ if (ofnW->nMaxFile &&
+ !WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
lfs->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
lfs->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
lfs->ofnA->nFileOffset = ofnW->nFileOffset;