diff --git a/2.x/trunk/CHANGELOG.txt b/2.x/trunk/CHANGELOG.txt index 88b3daaee..905ee9c9f 100644 --- a/2.x/trunk/CHANGELOG.txt +++ b/2.x/trunk/CHANGELOG.txt @@ -8,6 +8,7 @@ Process Hacker * Image file versions * Workaround for an IPv6-related bug in Windows XP * DPCs and Interrupts in System Information tooltips + * File dialog crash on Windows XP 2.14 * NEW/IMPROVED: diff --git a/2.x/trunk/phlib/support.c b/2.x/trunk/phlib/support.c index e2c995e41..861ce7a4d 100644 --- a/2.x/trunk/phlib/support.c +++ b/2.x/trunk/phlib/support.c @@ -4177,6 +4177,7 @@ VOID PhSetFileDialogFileName( else { OPENFILENAME *ofn = (OPENFILENAME *)FileDialog; + SIZE_T length; if (wcschr(FileName, '/') || wcschr(FileName, '\"')) { @@ -4185,8 +4186,11 @@ VOID PhSetFileDialogFileName( } PhFree(ofn->lpstrFile); - ofn->nMaxFile = max((ULONG)wcslen(FileName) + 1, 0x400); - ofn->lpstrFile = PhAllocateCopy(FileName, ofn->nMaxFile * 2); + + length = wcslen(FileName); + ofn->nMaxFile = max(length + 1, 0x400); + ofn->lpstrFile = PhAllocate(ofn->nMaxFile * 2); + memcpy(ofn->lpstrFile, FileName, (length + 1) * 2); } }