FEAT_GUI_MOTIF / FEAT_GUI_DIALOG), e.g. a Motif-enabled gvim.gui_mch_dialog() in src/gui_motif.c).XmStringCreate() to fail for the first button label (out-of-memory / Motif string allocation failure) while later setup still continues.butcount == 0, then the default-button clamp still runs and uses buttons[dfltbutton - 1].src/gui_motif.c):for (butcount = 0; *p; ++butcount) { ... label = XmStringCreate(_((char *)p), STRING_TAG); if (label == NULL) break; buttons[butcount] = XtVaCreateManagedWidget(...); ... } if (dfltbutton < 1) dfltbutton = 1; if (dfltbutton > butcount) dfltbutton = butcount; /* becomes 0 when butcount==0 */ XtVaSetValues(dialogform, XmNdefaultButton, buttons[dfltbutton - 1], NULL); /* buttons[-1] */
There is no butcount == 0 guard before the buttons[dfltbutton - 1] access.
If no buttons were successfully created (butcount == 0), gui_mch_dialog() should abort cleanly (destroy the dialog / return an error) and must not index buttons[-1] or pass an invalid widget pointer to Motif/XtVaSetValues.
9.2.0838 (git master @ 27cfd1c)
Operating system: Linux / Unix with Motif GUI
Terminal: n/a (GUI Motif build)
Value of $TERM: n/a
Shell: n/a
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
The report is technically correct: if XmStringCreate() fails for the first
button, the loop breaks with butcount == 0, dfltbutton is clamped to 0, and
buttons[dfltbutton - 1] reads buttons[-1].
Note this only occurs on allocation failure and only with the (legacy) Motif
GUI, so there is no script-reproducible case and no regression test is possible.
The guard below matches the existing error path a few lines down (the
XmStringCreateLtoR NULL check): free buttons and return -1 rather than
destroying the dialog.
--- a/src/gui_motif.c +++ b/src/gui_motif.c @@ -2777,6 +2777,12 @@ gui_mch_dialog( NULL); } + if (butcount == 0) + { + // No button could be created (XmStringCreate() failed: out of memory). + vim_free(buttons); + return -1; + }
if (dfltbutton < 1)
dfltbutton = 1;
if (dfltbutton > butcount)Please do not post AI-generated (LLM) content as-is.
You must verify it yourself before posting.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()