Tcl Source Code

Check-in [5313bef77f]
Login

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

Overview
Comment:Avoid segfaults when RecordByteCodeStats() is called in a deleted interp.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: 5313bef77feff7eb7f1e014636d156250e050315
User & Date: dgp 2011-07-15 17:50:20
Context
2011-07-21
16:19
[Bug 3372130] Fix hypot math function with MSVC10 check-in: 29cb474297 user: jan.nijtmans tags: core-8-4-branch
2011-07-15
17:53
Avoid segfaults when RecordByteCodeStats() is called in a deleted interp. check-in: 002be5a1c3 user: dgp tags: core-8-5-branch
17:50
Avoid segfaults when RecordByteCodeStats() is called in a deleted interp. check-in: 5313bef77f user: dgp tags: core-8-4-branch
2011-07-13
17:53
3366265 Buffer allocated one byte too small caused overrun. check-in: 9d68baec02 user: dgp tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2011-07-13  Don Porter  <[email protected]>

	* generic/tclProc.c:	[Bug 3366265] Buffer for storing the command
	* tests/indexObj.test:	name formatted as a list element is allocated
	* tests/proc.test:	one byte too small, causing buffer overflow
	when the proc with the empty name raises a "wrong num args" error.

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2011-07-15  Don Porter  <[email protected]>

	* generic/tclCompile.c: Avoid segfaults when RecordByteCodeStats()
	is called in a deleted interp.

2011-07-13  Don Porter  <[email protected]>

	* generic/tclProc.c:	[Bug 3366265] Buffer for storing the command
	* tests/indexObj.test:	name formatted as a list element is allocated
	* tests/proc.test:	one byte too small, causing buffer overflow
	when the proc with the empty name raises a "wrong num args" error.

Changes to generic/tclCompile.c.

4007
4008
4009
4010
4011
4012
4013





4014
4015
4016
4017
4018
4019
4020
void
RecordByteCodeStats(codePtr)
    ByteCode *codePtr;		/* Points to ByteCode structure with info
				 * to add to accumulated statistics. */
{
    Interp *iPtr = (Interp *) *codePtr->interpHandle;
    register ByteCodeStats *statsPtr = &(iPtr->stats);






    statsPtr->numCompilations++;
    statsPtr->totalSrcBytes        += (double) codePtr->numSrcBytes;
    statsPtr->totalByteCodeBytes   += (double) codePtr->structureSize;
    statsPtr->currentSrcBytes      += (double) codePtr->numSrcBytes;
    statsPtr->currentByteCodeBytes += (double) codePtr->structureSize;
    







>
>
>
>
>







4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
void
RecordByteCodeStats(codePtr)
    ByteCode *codePtr;		/* Points to ByteCode structure with info
				 * to add to accumulated statistics. */
{
    Interp *iPtr = (Interp *) *codePtr->interpHandle;
    register ByteCodeStats *statsPtr = &(iPtr->stats);

    if (iPtr == NULL) {
	/* Avoid segfaulting in case we're called in a deleted interp */
	return;
    }

    statsPtr->numCompilations++;
    statsPtr->totalSrcBytes        += (double) codePtr->numSrcBytes;
    statsPtr->totalByteCodeBytes   += (double) codePtr->structureSize;
    statsPtr->currentSrcBytes      += (double) codePtr->numSrcBytes;
    statsPtr->currentByteCodeBytes += (double) codePtr->structureSize;