summaryrefslogtreecommitdiffstats
path: root/generic
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)
commitd92d307894b14bbb065fdb65c5158f391da00cf1 (patch)
tree749d6f725f8785433f74fc0d60150e04bcb9b66b /generic
parent1153a9400bcdb471e1475c0e40dcf722dd5afc1a (diff)
parent8a43b2fbb57dcf1d1b9ccc26aa65e39263dc65dc (diff)
downloadtcl-d92d307894b14bbb065fdb65c5158f391da00cf1.zip
tcl-d92d307894b14bbb065fdb65c5158f391da00cf1.tar.gz
tcl-d92d307894b14bbb065fdb65c5158f391da00cf1.tar.bz2
More symmetric Tcl_(Incr|Decr)RefCount call, preventing bugs like #3601260 and #3602706
Diffstat (limited to 'generic')
-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;
}