Index: generic/nsf.c =================================================================== diff -u -r9fafad1fd703c9ee24aa9b32d820c313853bf2b5 -r40bdea07b98d57764934341d86f4e734bc0c0c9a --- generic/nsf.c (.../nsf.c) (revision 9fafad1fd703c9ee24aa9b32d820c313853bf2b5) +++ generic/nsf.c (.../nsf.c) (revision 40bdea07b98d57764934341d86f4e734bc0c0c9a) @@ -14610,13 +14610,24 @@ ObjStr(objPtr), ObjStr(Tcl_GetObjResult(interp)), pPtr, pPtr->flags & NSF_ARG_IS_CONVERTER);*/ if (pPtr->flags & NSF_ARG_IS_CONVERTER) { + Tcl_Obj *resultObj; /* * If we want to convert, the resulting obj is the result of the * converter. incr refCount is necessary e.g. for e.g. + * * return [expr {$value + 1}] + * + * The conversion is just needed, when resultObj differs from the actual + * value in the output vector. Otherwise the conversion and the value + * increment happened already before (and is already recorded in the + * parse context). */ - *outObjPtr = Tcl_GetObjResult(interp); - INCR_REF_COUNT2("valueObj", *outObjPtr); + resultObj = Tcl_GetObjResult(interp); + + if (*outObjPtr != resultObj) { + INCR_REF_COUNT2("valueObj", resultObj); + *outObjPtr = resultObj; + } /*fprintf(stderr, "**** NSF_ARG_IS_CONVERTER %p\n", *outObjPtr);*/ } *clientData = (ClientData) *outObjPtr;