From 8584690093094721708f417633f2ef9f0c6c8864 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 26 Jun 2007 03:12:35 +0000 Subject: * generic/tclExecute.c: Safety checks to avoid crashes in the TclStack* routines when called with an incompletely initialized interp. [Bug 1743302] --- ChangeLog | 6 ++++++ generic/tclExecute.c | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1db5ba6..25cc956 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-06-25 Don Porter + + * generic/tclExecute.c: Safety checks to avoid crashes in the + TclStack* routines when called with an incompletely initialized + interp. [Bug 1743302] + 2007-06-25 Miguel Sofer * generic/tclVar.c (UnsetVarStruct): fixing incomplete change, diff --git a/generic/tclExecute.c b/generic/tclExecute.c index d51c8fd..56981be 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -12,7 +12,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.303 2007/06/22 17:09:17 dgp Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.304 2007/06/26 03:12:35 dgp Exp $ */ #include "tclInt.h" @@ -815,12 +815,12 @@ TclStackFree( Tcl_Interp *interp, void *freePtr) { - Interp *iPtr; + Interp *iPtr = (Interp *) interp; ExecEnv *eePtr; ExecStack *esPtr; Tcl_Obj **markerPtr; - if (interp == NULL) { + if (iPtr == NULL || iPtr->execEnvPtr == NULL) { Tcl_Free((char *) freePtr); return; } @@ -831,7 +831,6 @@ TclStackFree( * the previous marker. */ - iPtr = (Interp *) interp; eePtr = iPtr->execEnvPtr; esPtr = eePtr->execStackPtr; markerPtr = esPtr->markerPtr; @@ -867,9 +866,10 @@ TclStackAlloc( Tcl_Interp *interp, int numBytes) { + Interp *iPtr = (Interp *) interp; int numWords = (numBytes + (sizeof(Tcl_Obj *) - 1))/sizeof(Tcl_Obj *); - if (interp == NULL) { + if (iPtr == NULL || iPtr->execEnvPtr == NULL) { return (void *) Tcl_Alloc(numBytes); } @@ -882,17 +882,16 @@ TclStackRealloc( void *ptr, int numBytes) { - Interp *iPtr; + Interp *iPtr = (Interp *) interp; ExecEnv *eePtr; ExecStack *esPtr; Tcl_Obj **markerPtr; int numWords; - if (interp == NULL) { + if (iPtr == NULL || iPtr->execEnvPtr == NULL) { return (void *) Tcl_Realloc((char *) ptr, numBytes); } - iPtr = (Interp *) interp; eePtr = iPtr->execEnvPtr; esPtr = eePtr->execStackPtr; markerPtr = esPtr->markerPtr; -- cgit v0.12