Tcl Source Code

Check-in [2b48a5d43c]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed memory leak in TclOO.c:ObjectNamespaceDeleted, object mixins and object/class mutation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rc2 | core-8-6-9-rc
Files: files | file ages | folders
SHA3-256: 2b48a5d43cc8823859ccc50d7ad1fc0b4f2e075eb6256d84c09787255e95b837
User & Date: dgp 2018-11-02 17:18:57
Context
2018-11-08
17:06
[86d249bcba] Make sure that tcltest::runAllTests actually returns 1 on failure Repairs TIP 525 imple... check-in: 63b4305a16 user: dgp tags: core-8-6-9-rc
2018-11-02
17:18
Fixed memory leak in TclOO.c:ObjectNamespaceDeleted, object mixins and object/class mutation. check-in: 2b48a5d43c user: dgp tags: rc2, core-8-6-9-rc
2018-11-01
20:10
Fixed memory leak in TclOO.c:ObjectNamespaceDeleted, object mixins and object/class mutation. check-in: 1e3b9149a7 user: pooryorick tags: core-8-branch
16:31
make dist check-in: cfb6cd8bde user: dgp tags: core-8-6-9-rc
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclOO.c.

1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
....
1145
1146
1147
1148
1149
1150
1151

1152

1153
1154
1155
1156
1157
1158
1159
....
1345
1346
1347
1348
1349
1350
1351




1352
1353
1354
1355
1356
1357
1358
    if (i) {
	ckfree(clsPtr->variables.list);
    }

    if (IsRootClass(oPtr) && !Deleted(fPtr->objectCls->thisPtr)) {
	Tcl_DeleteCommandFromToken(interp, fPtr->objectCls->thisPtr->command);
    }
    oPtr->classPtr = NULL;
}
 
/*
 * ----------------------------------------------------------------------
 *
 * ObjectNamespaceDeleted --
 *
................................................................................
    TclOORemoveFromInstances(oPtr, oPtr->selfCls);

    if (oPtr->mixins.num > 0) {
	FOREACH(mixinPtr, oPtr->mixins) {
	    TclOORemoveFromInstances(oPtr, mixinPtr);
	    TclOODecrRefCount(mixinPtr->thisPtr);
	}

	ckfree(oPtr->mixins.list);

    }

    FOREACH(filterObj, oPtr->filters) {
	TclDecrRefCount(filterObj);
    }
    if (i) {
	ckfree(oPtr->filters.list);
................................................................................
    FOREACH(mixPtr, oPtr->mixins) {
	if (mixinPtr == mixPtr) {
	    RemoveItem(Class, oPtr->mixins, i);
	    TclOODecrRefCount(mixPtr->thisPtr);
	    res++;
	    break;
	}




    }
    return res;
}
 
/*
 * ----------------------------------------------------------------------
 *






<







 







>
|
>







 







>
>
>
>







1031
1032
1033
1034
1035
1036
1037

1038
1039
1040
1041
1042
1043
1044
....
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
....
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
    if (i) {
	ckfree(clsPtr->variables.list);
    }

    if (IsRootClass(oPtr) && !Deleted(fPtr->objectCls->thisPtr)) {
	Tcl_DeleteCommandFromToken(interp, fPtr->objectCls->thisPtr->command);
    }

}
 
/*
 * ----------------------------------------------------------------------
 *
 * ObjectNamespaceDeleted --
 *
................................................................................
    TclOORemoveFromInstances(oPtr, oPtr->selfCls);

    if (oPtr->mixins.num > 0) {
	FOREACH(mixinPtr, oPtr->mixins) {
	    TclOORemoveFromInstances(oPtr, mixinPtr);
	    TclOODecrRefCount(mixinPtr->thisPtr);
	}
	if (oPtr->mixins.list != NULL) {
	    ckfree(oPtr->mixins.list);
	}
    }

    FOREACH(filterObj, oPtr->filters) {
	TclDecrRefCount(filterObj);
    }
    if (i) {
	ckfree(oPtr->filters.list);
................................................................................
    FOREACH(mixPtr, oPtr->mixins) {
	if (mixinPtr == mixPtr) {
	    RemoveItem(Class, oPtr->mixins, i);
	    TclOODecrRefCount(mixPtr->thisPtr);
	    res++;
	    break;
	}
    }
    if (oPtr->mixins.num == 0) {
	ckfree(oPtr->mixins.list);
	oPtr->mixins.list = NULL;
    }
    return res;
}
 
/*
 * ----------------------------------------------------------------------
 *

Changes to generic/tclOODefineCmds.c.

1153
1154
1155
1156
1157
1158
1159


1160
1161
1162
1163
1164
1165
1166
	    TclOORemoveFromMixins(oPtr->classPtr, oPtr);
	    oPtr->fPtr->epoch++;
	    oPtr->flags |= DONT_DELETE;
	    TclOODeleteDescendants(interp, oPtr);
	    oPtr->flags &= ~DONT_DELETE;
	    TclOOReleaseClassContents(interp, oPtr);


	} else if (!wasClass && willBeClass) {
	    TclOOAllocClass(interp, oPtr);
	}

	if (oPtr->classPtr != NULL) {
	    BumpGlobalEpoch(interp, oPtr->classPtr);
	} else {






>
>







1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
	    TclOORemoveFromMixins(oPtr->classPtr, oPtr);
	    oPtr->fPtr->epoch++;
	    oPtr->flags |= DONT_DELETE;
	    TclOODeleteDescendants(interp, oPtr);
	    oPtr->flags &= ~DONT_DELETE;
	    TclOOReleaseClassContents(interp, oPtr);
		ckfree(oPtr->classPtr);
		oPtr->classPtr = NULL;
	} else if (!wasClass && willBeClass) {
	    TclOOAllocClass(interp, oPtr);
	}

	if (oPtr->classPtr != NULL) {
	    BumpGlobalEpoch(interp, oPtr->classPtr);
	} else {