summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2012-09-11 14:02:58 (GMT)
committerdgp <dgp@users.sourceforge.net>2012-09-11 14:02:58 (GMT)
commita691e3e94617652a15c76afc630e9869cd7ae6cd (patch)
treea0855b0a6d614b327c109468580a13c5eb2e6a1d
parentedd591e8fbb5a6def7fbe9ca0d8e3f22c0e9cd56 (diff)
parent41d7976a599beb50796eb6a1316080825fb79047 (diff)
downloadtcl-a691e3e94617652a15c76afc630e9869cd7ae6cd.zip
tcl-a691e3e94617652a15c76afc630e9869cd7ae6cd.tar.gz
tcl-a691e3e94617652a15c76afc630e9869cd7ae6cd.tar.bz2
3564735 Protect against mem corruption when var resolvers misbehave.
-rw-r--r--generic/tclInt.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index e1ce6d5..cca9938 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -693,13 +693,17 @@ typedef struct VarInHash {
#define TclSetVarNamespaceVar(varPtr) \
if (!TclIsVarNamespaceVar(varPtr)) {\
(varPtr)->flags |= VAR_NAMESPACE_VAR;\
- ((VarInHash *)(varPtr))->refCount++;\
+ if (TclIsVarInHash(varPtr)) {\
+ ((VarInHash *)(varPtr))->refCount++;\
+ }\
}
#define TclClearVarNamespaceVar(varPtr) \
if (TclIsVarNamespaceVar(varPtr)) {\
(varPtr)->flags &= ~VAR_NAMESPACE_VAR;\
- ((VarInHash *)(varPtr))->refCount--;\
+ if (TclIsVarInHash(varPtr)) {\
+ ((VarInHash *)(varPtr))->refCount--;\
+ }\
}
/*