Index: .github/workflows/linux-build.yml ================================================================== --- .github/workflows/linux-build.yml +++ .github/workflows/linux-build.yml @@ -3,10 +3,11 @@ push: branches: - "main" - "core-8-branch" - "core-8-6-branch" + - "bug-8ce672d1a1" tags: - "core-**" permissions: contents: read defaults: Index: .github/workflows/mac-build.yml ================================================================== --- .github/workflows/mac-build.yml +++ .github/workflows/mac-build.yml @@ -3,10 +3,11 @@ push: branches: - "main" - "core-8-branch" - "core-8-6-branch" + - "bug-8ce672d1a1" tags: - "core-**" permissions: contents: read env: Index: .github/workflows/win-build.yml ================================================================== --- .github/workflows/win-build.yml +++ .github/workflows/win-build.yml @@ -3,10 +3,11 @@ push: branches: - "main" - "core-8-branch" - "core-8-6-branch" + - "bug-8ce672d1a1" tags: - "core-**" permissions: contents: read env: Index: generic/tkMenu.c ================================================================== --- generic/tkMenu.c +++ generic/tkMenu.c @@ -998,30 +998,42 @@ int index) /* The zero based index of the item we are * invoking. */ { int result = TCL_OK; TkMenuEntry *mePtr; + Tcl_Obj *commandPtr = NULL, *namePtr = NULL; if (index < 0) { goto done; } mePtr = menuPtr->entries[index]; if (mePtr->state == ENTRY_DISABLED) { goto done; } - Tcl_Preserve(mePtr); + if (mePtr->commandPtr != NULL) { + commandPtr = mePtr->commandPtr; + Tcl_IncrRefCount(commandPtr); + } + if ((mePtr->type == CHECK_BUTTON_ENTRY) || + (mePtr->type == RADIO_BUTTON_ENTRY)) { + if (mePtr->namePtr != NULL) { + namePtr = mePtr->namePtr; + Tcl_IncrRefCount(namePtr); + } + } + if (mePtr->type == TEAROFF_ENTRY) { Tcl_DString ds; Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, "tk::TearOffMenu ", -1); Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), -1); result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), -1, TCL_EVAL_GLOBAL); Tcl_DStringFree(&ds); } else if ((mePtr->type == CHECK_BUTTON_ENTRY) - && (mePtr->namePtr != NULL)) { + && (namePtr != NULL)) { Tcl_Obj *valuePtr; if (mePtr->entryFlags & ENTRY_SELECTED) { valuePtr = mePtr->offValuePtr; } else { @@ -1029,24 +1041,24 @@ } if (valuePtr == NULL) { valuePtr = Tcl_NewObj(); } Tcl_IncrRefCount(valuePtr); - if (Tcl_ObjSetVar2(interp, mePtr->namePtr, NULL, valuePtr, + if (Tcl_ObjSetVar2(interp, namePtr, NULL, valuePtr, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { result = TCL_ERROR; } Tcl_DecrRefCount(valuePtr); } else if ((mePtr->type == RADIO_BUTTON_ENTRY) - && (mePtr->namePtr != NULL)) { + && (namePtr != NULL)) { Tcl_Obj *valuePtr = mePtr->onValuePtr; if (valuePtr == NULL) { valuePtr = Tcl_NewObj(); } Tcl_IncrRefCount(valuePtr); - if (Tcl_ObjSetVar2(interp, mePtr->namePtr, NULL, valuePtr, + if (Tcl_ObjSetVar2(interp, namePtr, NULL, valuePtr, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { result = TCL_ERROR; } Tcl_DecrRefCount(valuePtr); } @@ -1056,18 +1068,19 @@ * because that goes to zero if the menu gets deleted (e.g., during * command evaluation). */ if ((menuPtr->numEntries != 0) && (result == TCL_OK) - && (mePtr->commandPtr != NULL)) { - Tcl_Obj *commandPtr = mePtr->commandPtr; - - Tcl_IncrRefCount(commandPtr); + && (commandPtr != NULL)) { result = Tcl_EvalObjEx(interp, commandPtr, TCL_EVAL_GLOBAL); + } + if (commandPtr != NULL) { Tcl_DecrRefCount(commandPtr); } - Tcl_Release(mePtr); + if (namePtr != NULL) { + Tcl_DecrRefCount(namePtr); + } done: return result; }