summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclExecute.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 28c5dcd..0bd884d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2008-07-29 Miguel Sofer <msofer@users.sf.net>
+ * generic/tclExecute.c: fix [Bug 2030670] that cause
+ TclStackRealloc to panic on rare corner cases. Thx ajpasadyn for
+ diagnose and patch.
+
* generic/tcl.decls: Completely revamped NRE implementation,
* generic/tclBasic.c: with (almost) unchanged API.
* generic/tclCompile.h:
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 0aee386..0965d48 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.388 2008/07/29 05:30:26 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.389 2008/07/29 13:45:17 msofer Exp $
*/
#include "tclInt.h"
@@ -973,6 +973,7 @@ GrowEvaluationStack(
int newBytes, newElems, currElems;
int needed = growth - (esPtr->endPtr - esPtr->tosPtr);
Tcl_Obj **markerPtr = esPtr->markerPtr, **memStart;
+ int moveWords = 0;
if (move) {
if (!markerPtr) {
@@ -1007,9 +1008,9 @@ GrowEvaluationStack(
*/
if (move) {
- move = esPtr->tosPtr - MEMSTART(markerPtr) + 1;
+ moveWords = esPtr->tosPtr - MEMSTART(markerPtr) + 1;
}
- needed = growth + move + WALLOCALIGN - 1;
+ needed = growth + moveWords + WALLOCALIGN - 1;
/*
* Check if there is enough room in the next stack (if there is one, it
@@ -1069,8 +1070,8 @@ GrowEvaluationStack(
esPtr->tosPtr = memStart - 1;
if (move) {
- memcpy(memStart, MEMSTART(markerPtr), move*sizeof(Tcl_Obj *));
- esPtr->tosPtr += move;
+ memcpy(memStart, MEMSTART(markerPtr), moveWords*sizeof(Tcl_Obj *));
+ esPtr->tosPtr += moveWords;
oldPtr->markerPtr = (Tcl_Obj **) *markerPtr;
oldPtr->tosPtr = markerPtr-1;
}