Index: generic/nsf.c =================================================================== diff -u -r6042ab0563421425280b064579c53aa8daa2bc71 -r1a486b9a82c7dca914702329c0b17cc5e397c8c3 --- generic/nsf.c (.../nsf.c) (revision 6042ab0563421425280b064579c53aa8daa2bc71) +++ generic/nsf.c (.../nsf.c) (revision 1a486b9a82c7dca914702329c0b17cc5e397c8c3) @@ -12651,6 +12651,11 @@ DECR_REF_COUNT2("returnsObj", ctxPtr->returnsObj); } + if (ctxPtr->execNsPtr != NULL) { + /* Balances increment in ParamDefsStore */ + NSNamespaceRelease(ctxPtr->execNsPtr); + } + /*fprintf(stderr, "free %p\n", ctxPtr);*/ FREE(NsfProcContext, ctxPtr); } @@ -12774,11 +12779,15 @@ * We assume, that this never called for overwriting paramDefs */ assert(ctxPtr->paramDefs == NULL); - + /* fprintf(stderr, "ParamDefsStore paramDefs %p called: NS %s\n", paramDefs, execNsPtr ? execNsPtr->fullName : "na");*/ ctxPtr->paramDefs = paramDefs; ctxPtr->checkAlwaysFlag = checkAlwaysFlag; ctxPtr->execNsPtr = execNsPtr; - // xxxxx TODO: if the namespace can be lost, we have to incr namespace refcount and call TclNsDecrRefCount() on deallocation + + if (ctxPtr->execNsPtr != NULL) { + /* Balanced by decrement in NsfProcDeleteProc */ + NSNamespacePreserve(ctxPtr->execNsPtr); + } } /*