summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2012-09-11 14:07:27 (GMT)
committerdgp <dgp@users.sourceforge.net>2012-09-11 14:07:27 (GMT)
commit3110959c6f9095d249c2991f9f41fb27fa900c1a (patch)
tree62db53fb3029b4fbf6c6a9f4bb33dfd6ad2696fc
parentdf2aa14a4b12e5a43e8e757268e95e153cc31fdb (diff)
downloadtcl-3110959c6f9095d249c2991f9f41fb27fa900c1a.zip
tcl-3110959c6f9095d249c2991f9f41fb27fa900c1a.tar.gz
tcl-3110959c6f9095d249c2991f9f41fb27fa900c1a.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 53a88d6..6c6e664 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -801,13 +801,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--;\
+ }\
}
/*