Skip to content

Commit 80e4e6f

Browse files
author
jan.nijtmans
committed
Handle TclVarHashCreateVar() returning NULL
1 parent 33a4858 commit 80e4e6f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

generic/itclCmd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,10 +1860,9 @@ Itcl_AddComponentCmd(
18601860
Tcl_GetString(ivPtr->namePtr));
18611861
hPtr = Tcl_CreateHashEntry(&contextIoPtr->objectVariables,
18621862
(char *)ivPtr, &isNew);
1863-
if (isNew) {
1863+
if (hPtr && isNew) {
18641864
Itcl_PreserveVar(varPtr);
1865-
Tcl_SetHashValue(hPtr, varPtr);
1866-
} else {
1865+
Tcl_SetHashValue(hPtr, varPtr);
18671866
}
18681867
return result;
18691868
}

generic/itclMigrate2TclCore.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ Tcl_NewNamespaceVar(
6767

6868
varPtr = TclVarHashCreateVar(&((Namespace *)nsPtr)->varTable,
6969
varName, &isNew);
70-
TclSetVarNamespaceVar(varPtr);
70+
if (varPtr) {
71+
TclSetVarNamespaceVar(varPtr);
72+
}
7173
return (Tcl_Var)varPtr;
7274
}
7375

0 commit comments

Comments
 (0)