summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-02-03 11:34:01 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-02-03 11:34:01 (GMT)
commit9088907888b8deb7fcd5748c0dcc4472130ee10b (patch)
tree749d6f725f8785433f74fc0d60150e04bcb9b66b /generic/tclVar.c
parent8f72fe1eb9bdbf2e439c3c168d1199ab6a7790d1 (diff)
parent7ee439ce0f9c58f54ccb118e8dcffe7a9dc9e1d9 (diff)
downloadtcl-9088907888b8deb7fcd5748c0dcc4472130ee10b.zip
tcl-9088907888b8deb7fcd5748c0dcc4472130ee10b.tar.gz
tcl-9088907888b8deb7fcd5748c0dcc4472130ee10b.tar.bz2
More symmetric Tcl_(Incr|Decr)RefCount call, preventing bugs like #3601260 and #3602706
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 2d1479d..e780d47 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -475,6 +475,7 @@ TclObjLookupVar(
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
+ Tcl_IncrRefCount(part2Ptr);
}
resPtr = TclObjLookupVarEx(interp, part1Ptr, part2Ptr,
@@ -1324,8 +1325,10 @@ Tcl_GetVar2Ex(
{
Tcl_Obj *resPtr, *part2Ptr = NULL, *part1Ptr = Tcl_NewStringObj(part1, -1);
+ Tcl_IncrRefCount(part1Ptr);
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
+ Tcl_IncrRefCount(part2Ptr);
}
resPtr = Tcl_ObjGetVar2(interp, part1Ptr, part2Ptr, flags);
@@ -2218,8 +2221,10 @@ Tcl_UnsetVar2(
int result;
Tcl_Obj *part2Ptr = NULL, *part1Ptr = Tcl_NewStringObj(part1, -1);
+ Tcl_IncrRefCount(part1Ptr);
if (part2) {
part2Ptr = Tcl_NewStringObj(part2, -1);
+ Tcl_IncrRefCount(part2Ptr);
}
/*
@@ -3088,7 +3093,7 @@ ArrayStartSearchCmd(
Tcl_ObjPrintf("s-%d-%s", searchPtr->id, varName));
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -3194,7 +3199,7 @@ ArrayAnyMoreCmd(
Tcl_SetObjResult(interp, iPtr->execEnvPtr->constants[gotValue]);
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -5778,6 +5783,7 @@ Tcl_FindNamespaceVar(
Tcl_Obj *namePtr = Tcl_NewStringObj(name, -1);
Tcl_Var var;
+ Tcl_IncrRefCount(namePtr);
var = ObjFindNamespaceVar(interp, namePtr, contextNsPtr, flags);
Tcl_DecrRefCount(namePtr);
return var;
@@ -5872,6 +5878,7 @@ ObjFindNamespaceVar(
varPtr = NULL;
if (simpleName != name) {
simpleNamePtr = Tcl_NewStringObj(simpleName, -1);
+ Tcl_IncrRefCount(simpleNamePtr);
} else {
simpleNamePtr = namePtr;
}