diff options
author | mig <mig> | 2013-01-04 05:26:40 (GMT) |
---|---|---|
committer | mig <mig> | 2013-01-04 05:26:40 (GMT) |
commit | 047d22960723097544bbeda5eefb066d71b7e38f (patch) | |
tree | c6a56776e78090be844eacac0d757f5cb932b267 /generic | |
parent | f889a9294bd1a1c5df632d4ff4919abf81d72127 (diff) | |
download | tcl-047d22960723097544bbeda5eefb066d71b7e38f.zip tcl-047d22960723097544bbeda5eefb066d71b7e38f.tar.gz tcl-047d22960723097544bbeda5eefb066d71b7e38f.tar.bz2 |
Insure that PURIFY builds cannot exploit the Tcl stack to hide mem defects.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclExecute.c | 14 | ||||
-rw-r--r-- | generic/tclInt.h | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 9fcc8a5..3635bab 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1048,6 +1048,7 @@ GrowEvaluationStack( return MEMSTART(markerPtr); } } else { +#ifndef PURIFY Tcl_Obj **tmpMarkerPtr = esPtr->tosPtr + 1; int offset = OFFSET(tmpMarkerPtr); @@ -1064,6 +1065,7 @@ GrowEvaluationStack( *esPtr->markerPtr = (Tcl_Obj *) markerPtr; return memStart; } +#endif } /* @@ -1075,8 +1077,9 @@ GrowEvaluationStack( if (move) { moveWords = esPtr->tosPtr - MEMSTART(markerPtr) + 1; } - needed = growth + moveWords + WALLOCALIGN; + needed = growth + moveWords + WALLOCALIGN - 1; + /* * Check if there is enough room in the next stack (if there is one, it * should be both empty and the last one!) @@ -1106,10 +1109,15 @@ GrowEvaluationStack( * including the elements to be copied over and the new marker. */ +#ifndef PURIFY newElems = 2*currElems; while (needed > newElems) { newElems *= 2; } +#else + newElems = needed; +#endif + newBytes = sizeof(ExecStack) + (newElems-1) * sizeof(Tcl_Obj *); oldPtr = esPtr; @@ -1258,6 +1266,10 @@ TclStackFree( } if (esPtr->prevPtr) { eePtr->execStackPtr = esPtr->prevPtr; +#ifdef PURIFY + eePtr->execStackPtr->nextPtr = NULL; + DeleteExecStack(esPtr); +#endif } else { eePtr->execStackPtr = esPtr; } diff --git a/generic/tclInt.h b/generic/tclInt.h index 52f1a32..dd3c1cd 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4014,6 +4014,7 @@ typedef const char *TclDTraceStr; ckfree((char *) (objPtr)) #undef USE_THREAD_ALLOC +#undef USE_TCLALLOC #elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) /* |