Tcl Source Code

Check-in [ad62499767]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[Bug 3362446]: possible allocation error when using UNICODE
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: ad62499767ce33e6ff49ce433d2823f4495afc43
User & Date: jan.nijtmans 2012-06-21 10:59:15
Context
2012-06-23
06:59
[Bug 3508771]: Cygwin notifier for handling win32 events check-in: 0741b45cd7 user: jan.nijtmans tags: core-8-4-branch
2012-06-22
08:29
first working version of Cygwin notifier Closed-Leaf check-in: e93625f4c5 user: jan.nijtmans tags: bug-3508771
2012-06-21
11:02
[Bug 3362446]: possible allocation error when using UNICODE check-in: 38a393d995 user: jan.nijtmans tags: core-8-5-branch
10:59
[Bug 3362446]: possible allocation error when using UNICODE check-in: ad62499767 user: jan.nijtmans tags: core-8-4-branch
2012-06-20
19:36
Purge more dead fs path code. check-in: 7b2432f00f user: dgp tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to win/tclWinReg.c.

727
728
729
730
731
732
733

734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
     * should be safer if the implementation of Dstrings changes.
     *
     * This allows short values to be read from the registy in one call.
     * Longer values need a second call with an expanded DString.
     */

    Tcl_DStringInit(&data);

    length = TCL_DSTRING_STATIC_SIZE - 1;
    Tcl_DStringSetLength(&data, (int) length);

    resultPtr = Tcl_GetObjResult(interp);

    valueName = Tcl_GetStringFromObj(valueNameObj, &nameLen);
    nativeValue = Tcl_WinUtfToTChar(valueName, nameLen, &buf);

    result = (*regWinProcs->regQueryValueExProc)(key, nativeValue, NULL, &type,
	    (BYTE *) Tcl_DStringValue(&data), &length);
    while (result == ERROR_MORE_DATA) {
	/*
	 * The Windows docs say that in this error case, we just need
	 * to expand our buffer and request more data.
	 * Required for HKEY_PERFORMANCE_DATA
	 */
	length *= 2;
        Tcl_DStringSetLength(&data, (int) length);
        result = (*regWinProcs->regQueryValueExProc)(key, (char *) nativeValue,
		NULL, &type, (BYTE *) Tcl_DStringValue(&data), &length);
    }
    Tcl_DStringFree(&buf);
    RegCloseKey(key);
    if (result != ERROR_SUCCESS) {
	Tcl_AppendStringsToObj(resultPtr, "unable to get value \"",
		Tcl_GetString(valueNameObj), "\" from key \"",







>
|
<















|
|







727
728
729
730
731
732
733
734
735

736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
     * should be safer if the implementation of Dstrings changes.
     *
     * This allows short values to be read from the registy in one call.
     * Longer values need a second call with an expanded DString.
     */

    Tcl_DStringInit(&data);
    Tcl_DStringSetLength(&data, TCL_DSTRING_STATIC_SIZE - 1);
    length = TCL_DSTRING_STATIC_SIZE / (regWinProcs->useWide ? 2 : 1) - 1;


    resultPtr = Tcl_GetObjResult(interp);

    valueName = Tcl_GetStringFromObj(valueNameObj, &nameLen);
    nativeValue = Tcl_WinUtfToTChar(valueName, nameLen, &buf);

    result = (*regWinProcs->regQueryValueExProc)(key, nativeValue, NULL, &type,
	    (BYTE *) Tcl_DStringValue(&data), &length);
    while (result == ERROR_MORE_DATA) {
	/*
	 * The Windows docs say that in this error case, we just need
	 * to expand our buffer and request more data.
	 * Required for HKEY_PERFORMANCE_DATA
	 */
	length *= 2;
	Tcl_DStringSetLength(&data, (int) length * (regWinProcs->useWide ? 2 : 1));
	result = (*regWinProcs->regQueryValueExProc)(key, (char *) nativeValue,
		NULL, &type, (BYTE *) Tcl_DStringValue(&data), &length);
    }
    Tcl_DStringFree(&buf);
    RegCloseKey(key);
    if (result != ERROR_SUCCESS) {
	Tcl_AppendStringsToObj(resultPtr, "unable to get value \"",
		Tcl_GetString(valueNameObj), "\" from key \"",