Index: generic/nsf.c =================================================================== diff -u -N -rae081c0f1926da915e0584d8561abaa8a2a022a4 -r0e8f3a70673d4c0b005344a8520f05913939de9b --- generic/nsf.c (.../nsf.c) (revision ae081c0f1926da915e0584d8561abaa8a2a022a4) +++ generic/nsf.c (.../nsf.c) (revision 0e8f3a70673d4c0b005344a8520f05913939de9b) @@ -26212,16 +26212,16 @@ if (class->super != NULL) { NsfObject *matchObject = NULL; - Tcl_Obj *outObjPtr; + Tcl_Obj *outObjPtr, *patternObj = NULL; const char *patternString = NULL; ClientData clientData; bool found; if (pattern != NULL && ConvertToObjpattern(interp, pattern, NULL, &clientData, &outObjPtr) == TCL_OK ) { - Tcl_Obj *patternObj = (Tcl_Obj *)clientData; - + patternObj = (Tcl_Obj *)clientData; + if (GetMatchObject(interp, patternObj, pattern, &matchObject, &patternString) == -1) { /* * The pattern has no meta chars and does not correspond to an existing @@ -26232,12 +26232,8 @@ } return TCL_OK; } - - if (patternObj != NULL) { - DECR_REF_COUNT2("patternObj", patternObj); - } } - + if (withClosure) { NsfClasses *pl = PrecedenceOrder(class); @@ -26256,6 +26252,10 @@ Tcl_SetObjResult(interp, found ? matchObject->cmdName : NsfGlobalObjs[NSF_EMPTY]); } + if (patternObj != NULL) { + DECR_REF_COUNT2("patternObj", patternObj); + } + } return TCL_OK; }