summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2025-09-22 10:34:22 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2025-09-22 10:34:22 (GMT)
commitb74718ee37115ce70b36b70a6fd197b8ff86857c (patch)
treee1e27e0d98114c7e0eac2a53c5bb310552c123ad
parenta847875480c40480b57e2c692a0cf929aba18b03 (diff)
downloadtcl-b74718ee37115ce70b36b70a6fd197b8ff86857c.zip
tcl-b74718ee37115ce70b36b70a6fd197b8ff86857c.tar.gz
tcl-b74718ee37115ce70b36b70a6fd197b8ff86857c.tar.bz2
Bug [c9e68eb6ca] - Windows versioncore-bug-c9e68eb6ca
-rw-r--r--win/tclWinInit.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 29e177d..3e4daab 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -221,6 +221,7 @@ AppendEnvironment(
{
int pathc;
WCHAR wBuf[MAX_PATH];
+ DWORD dw;
char buf[MAX_PATH * 3];
Tcl_Obj *objPtr;
Tcl_DString ds;
@@ -245,13 +246,14 @@ AppendEnvironment(
Tcl_Panic("no '/' character found in lib");
}
- /*
- * The "L" preceding the TCL_LIBRARY string is used to tell VC++ that
- * this is a Unicode string.
- */
-
- GetEnvironmentVariableW(L"TCL_LIBRARY", wBuf, MAX_PATH);
- WideCharToMultiByte(CP_UTF8, 0, wBuf, -1, buf, MAX_PATH * 3, NULL, NULL);
+ dw = GetEnvironmentVariableW(L"TCL_LIBRARY", wBuf, MAX_PATH);
+ if (dw <= 0 || dw >= (sizeof(buf) / sizeof(buf[0]))) {
+ return;
+ }
+ if (WideCharToMultiByte(
+ CP_UTF8, 0, wBuf, -1, buf, MAX_PATH * 3, NULL, NULL) == 0) {
+ return;
+ }
if (buf[0] != '\0') {
objPtr = Tcl_NewStringObj(buf, -1);