Index: dll/win32/shell32/shellord.cpp =================================================================== --- dll/win32/shell32/shellord.cpp (revision 58826) +++ dll/win32/shell32/shellord.cpp (working copy) @@ -1504,8 +1504,8 @@ * cchString [I] size of str. * * RETURNS - * cchString length in the HIWORD; - * TRUE in LOWORD if subst was successful and FALSE in other case + * If the expanded string fits the buffer: HIWORD(TRUE), LOWORD (length of expanded string); + * If the expanded string doesn't fit the buffer: HIWORD(FALSE), LOWORD (cchString); */ EXTERN_C DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString) { @@ -1522,9 +1522,11 @@ res = TRUE; memcpy(pszString, dst, num); } + else + num = cchString; HeapFree(GetProcessHeap(), 0, dst); } - return MAKELONG(res,cchString); /* Always cchString? */ + return MAKELONG(num,res); } /************************************************************************ @@ -1545,10 +1547,12 @@ res = TRUE; wcscpy(pszString, dst); } + else + num = cchString; HeapFree(GetProcessHeap(), 0, dst); } - return MAKELONG(res,cchString); + return MAKELONG(num,res); } /************************************************************************