summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-06-26 03:12:35 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-06-26 03:12:35 (GMT)
commit8584690093094721708f417633f2ef9f0c6c8864 (patch)
treec3dc99e6b2141aa0374c44204c33fae6d4afff51 /generic/tclExecute.c
parent3136efdb1c9f457809489f244bc836768099d6d6 (diff)
downloadtcl-8584690093094721708f417633f2ef9f0c6c8864.zip
tcl-8584690093094721708f417633f2ef9f0c6c8864.tar.gz
tcl-8584690093094721708f417633f2ef9f0c6c8864.tar.bz2
* generic/tclExecute.c: Safety checks to avoid crashes in the
TclStack* routines when called with an incompletely initialized interp. [Bug 1743302]
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c15
1 files changed, 7 insertions, 8 deletions
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;