summaryrefslogtreecommitdiffstats
path: root/generic/tclOODefineCmds.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2015-11-21 22:22:49 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2015-11-21 22:22:49 (GMT)
commit6b4bc6bb8d46722088d73bd4a93f51e7fc65dbf4 (patch)
tree0eeb703224f6ae757ab409e4196bc4b0ceb50199 /generic/tclOODefineCmds.c
parent67929efb233a934a2d625216ee8d3b1d8022d33e (diff)
downloadtcl-6b4bc6bb8d46722088d73bd4a93f51e7fc65dbf4.zip
tcl-6b4bc6bb8d46722088d73bd4a93f51e7fc65dbf4.tar.gz
tcl-6b4bc6bb8d46722088d73bd4a93f51e7fc65dbf4.tar.bz2
[3d96b7076e] Prevent crashes when destroying an object's class inside a method call.
Diffstat (limited to 'generic/tclOODefineCmds.c')
-rw-r--r--generic/tclOODefineCmds.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/generic/tclOODefineCmds.c b/generic/tclOODefineCmds.c
index 85f6c31..c880754 100644
--- a/generic/tclOODefineCmds.c
+++ b/generic/tclOODefineCmds.c
@@ -323,7 +323,9 @@ TclOOObjectSetMixins(
if (numMixins == 0) {
if (oPtr->mixins.num != 0) {
FOREACH(mixinPtr, oPtr->mixins) {
- TclOORemoveFromInstances(oPtr, mixinPtr);
+ if (mixinPtr) {
+ TclOORemoveFromInstances(oPtr, mixinPtr);
+ }
}
ckfree(oPtr->mixins.list);
oPtr->mixins.num = 0;
@@ -332,7 +334,7 @@ TclOOObjectSetMixins(
} else {
if (oPtr->mixins.num != 0) {
FOREACH(mixinPtr, oPtr->mixins) {
- if (mixinPtr != oPtr->selfCls) {
+ if (mixinPtr && mixinPtr != oPtr->selfCls) {
TclOORemoveFromInstances(oPtr, mixinPtr);
}
}
@@ -1213,6 +1215,9 @@ TclOODefineClassObjCmd(
TclOORemoveFromInstances(oPtr, oPtr->selfCls);
oPtr->selfCls = clsPtr;
TclOOAddToInstances(oPtr, oPtr->selfCls);
+ if (!(clsPtr->thisPtr->flags & OBJECT_DELETED)) {
+ oPtr->flags &= ~CLASS_GONE;
+ }
if (oPtr->classPtr != NULL) {
BumpGlobalEpoch(interp, oPtr->classPtr);
} else {
@@ -2509,8 +2514,10 @@ ObjMixinGet(
resultObj = Tcl_NewObj();
FOREACH(mixinPtr, oPtr->mixins) {
- Tcl_ListObjAppendElement(NULL, resultObj,
- TclOOObjectName(interp, mixinPtr->thisPtr));
+ if (mixinPtr) {
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ TclOOObjectName(interp, mixinPtr->thisPtr));
+ }
}
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;