Tk Source Code

Check-in [f38091d0]
Login

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

Overview
Comment:Don't use sizeof(struct) when the structure has a char array as last element: If the size of this array changes, we'll be in trouble.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-6-branch
Files: files | file ages | folders
SHA1: f38091d0fde7807f853c3fbd9ffc93c335365135
User & Date: jan.nijtmans 2017-05-08 11:18:52
References
2017-05-12
08:57
Revert [f38091d0]: If TK_LAYOUT_WITH_BASE_CHUNKS is set (MacOSX), this change leads to crash, struct CharInfo is defined differently depending on TK_LAYOUT_WITH_BASE_CHUNKS (however strange that is ...) check-in: 32310877 user: jan.nijtmans tags: core-8-6-branch
Context
2017-05-08
12:02
Remove calls to Tk_FreeXId(), since it's just a NOP. check-in: 5db3cc59 user: jan.nijtmans tags: core-8-6-branch
11:32
merge core-8-6-branch check-in: 080f0db7 user: jan.nijtmans tags: rfe-6c0d7aec67
11:20
merge core-8-6-branch check-in: f6078459 user: jan.nijtmans tags: trunk
11:18
Don't use sizeof(struct) when the structure has a char array as last element: If the size of this array changes, we'll be in trouble. check-in: f38091d0 user: jan.nijtmans tags: core-8-6-branch
2017-05-06
15:37
tk_getSaveFile now correctly displays multiple file types with filtering on macOS check-in: efc04f45 user: kevin_walzer tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkSelect.c.

186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
		selPtr->proc = proc;
		if (selPtr->proc == HandleTclCommand) {
		    /*
		     * The clientData is selection controlled memory, so we
		     * should make a copy for this selPtr.
		     */

		    unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) +
			    ((CommandInfo *)clientData)->cmdLength + 1;

		    selPtr->clientData = ckalloc(cmdInfoLen);
		    memcpy(selPtr->clientData, clientData, cmdInfoLen);
		} else {
		    selPtr->clientData = clientData;
		}
		selPtr->size = 8;







|
|







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
		selPtr->proc = proc;
		if (selPtr->proc == HandleTclCommand) {
		    /*
		     * The clientData is selection controlled memory, so we
		     * should make a copy for this selPtr.
		     */

		    unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) + 1 +
			    ((CommandInfo *)clientData)->cmdLength;

		    selPtr->clientData = ckalloc(cmdInfoLen);
		    memcpy(selPtr->clientData, clientData, cmdInfoLen);
		} else {
		    selPtr->clientData = clientData;
		}
		selPtr->size = 8;

Changes to generic/tkTextDisp.c.

7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
	baseString = &bciPtr->baseChars;
	Tcl_DStringInit(baseString);
	bciPtr->width = 0;

	ciPtr = &bciPtr->ci;
    } else {
	bciPtr = baseCharChunkPtr->clientData;
	ciPtr = ckalloc(sizeof(CharInfo));
	baseString = &bciPtr->baseChars;
    }

    lineOffset = Tcl_DStringLength(baseString);
    line = Tcl_DStringAppend(baseString,p,maxBytes);

    chunkPtr->clientData = ciPtr;







|







7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
	baseString = &bciPtr->baseChars;
	Tcl_DStringInit(baseString);
	bciPtr->width = 0;

	ciPtr = &bciPtr->ci;
    } else {
	bciPtr = baseCharChunkPtr->clientData;
	ciPtr = ckalloc(Tk_Offset(CharInfo, chars) + 1);
	baseString = &bciPtr->baseChars;
    }

    lineOffset = Tcl_DStringLength(baseString);
    line = Tcl_DStringAppend(baseString,p,maxBytes);

    chunkPtr->clientData = ciPtr;