From 989a8101fcd98ea1768732253c10b554aa99f9be Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 21 Jun 2012 10:56:52 +0000 Subject: [Bug 3362446]: possible allocation error when using UNICODE --- win/tclWinReg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/win/tclWinReg.c b/win/tclWinReg.c index de9f756..ee0c243 100644 --- a/win/tclWinReg.c +++ b/win/tclWinReg.c @@ -17,7 +17,6 @@ # define USE_TCL_STUBS #endif #include "tclInt.h" -#include "tclPort.h" #ifdef _MSC_VER # pragma comment (lib, "advapi32.lib") #endif @@ -766,8 +765,8 @@ GetValue( */ Tcl_DStringInit(&data); - length = TCL_DSTRING_STATIC_SIZE - 1; - Tcl_DStringSetLength(&data, (int) length); + Tcl_DStringSetLength(&data, (int) TCL_DSTRING_STATIC_SIZE - 1); + length = TCL_DSTRING_STATIC_SIZE/sizeof(TCHAR) - 1; valueName = Tcl_GetStringFromObj(valueNameObj, &nameLen); nativeValue = Tcl_WinUtfToTChar(valueName, nameLen, &buf); @@ -910,7 +909,7 @@ GetValueNames( size = MAX_KEY_LENGTH; while (RegEnumValue(key,index, (TCHAR *)Tcl_DStringValue(&buffer), &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - size *= 2; + size *= sizeof(TCHAR); Tcl_WinTCharToUtf((TCHAR *) Tcl_DStringValue(&buffer), (int) size, &ds); -- cgit v0.12