Revision: 9712 https://osdn.net/projects/ttssh2/scm/svn/commits/9712 Author: zmatsuo Date: 2022-01-31 01:13:53 +0900 (Mon, 31 Jan 2022) Log Message: ----------- _ExpandEnvironmentStringsW() バッファ長問い合わせに対応 Modified Paths: -------------- trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp -------------- next part -------------- Modified: trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp 2022-01-30 16:13:36 UTC (rev 9711) +++ trunk/teraterm/layer_for_unicode/layer_for_unicode.cpp 2022-01-30 16:13:53 UTC (rev 9712) @@ -740,8 +740,13 @@ char dstA[MAX_PATH]; // MAX_PATH? DWORD r = ExpandEnvironmentStringsA(srcA, dstA, sizeof(dstA)); wchar_t *dstW = ToWcharA(dstA); - wcsncpy_s(lpDst, nSize, dstW, _TRUNCATE); r = (DWORD)wcslen(dstW); + if (lpDst == NULL || nSize == 0) { + r++; + } + else { + wcsncpy_s(lpDst, nSize, dstW, _TRUNCATE); + } free(srcA); free(dstW); return r;