From cfc4082b03f88b169cf1aa9d114e36db51db3458 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 13 Oct 2002 17:52:32 +0000 Subject: [PATCH] Avoid crashes when ofnW->lpstrFile is null. --- dlls/commdlg/filedlg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dlls/commdlg/filedlg.c b/dlls/commdlg/filedlg.c index 5d609404ec1..3162a61b00c 100644 --- a/dlls/commdlg/filedlg.c +++ b/dlls/commdlg/filedlg.c @@ -669,8 +669,8 @@ void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr) 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 @@ void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr) } 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;