On Fri, 17 Sep 2010, Carlos R. Mafra wrote: > So if you can provide the format-patch with some explanations later, > that will be greatly appreciated.
>From 9e2dde8949f634c17eb3509c9c1f43df23e21075 Mon Sep 17 00:00:00 2001 From: Tamas TEVESZ <[email protected]> Date: Fri, 17 Sep 2010 20:57:50 +0200 Subject: [PATCH] Prevent a WPrefs segfault Prevent WPrefs (menu panel) segfaulting upon coming by an invalid command in the root menu. Reported and first patch version by Bento Loewenstein. --- WPrefs.app/Menu.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index 4751c1e..760b1f9 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -509,7 +509,7 @@ static void createPanel(_Panel * p) data->param.exec.command = "eterm"; data = putNewItem(panel, pad, ExecInfo, _("Run...")); - data->param.exec.command = _("%a(Run,Type command to run)"); + data->param.exec.command = _("%A(Run,Type command to run)"); data = putNewItem(panel, pad, ExecInfo, _("Netscape")); data->param.exec.command = "netscape"; @@ -1029,14 +1029,9 @@ static ItemData *parseCommand(WMPropList * item) } else if (strcmp(command, "LEGAL_PANEL") == 0) { cmd = 11; } else { - wwarning(_("unknown command '%s' in menu"), command); - command = wstrdup("EXEC"); - data->type = ExecInfo; - data->param.exec.command = wstrdup("invalid command"); - - return data; - + wfree(data); + return NULL; } data->type = CommandInfo; @@ -1397,13 +1392,21 @@ static WEditMenu *buildSubmenu(_Panel * panel, WMPropList * pl) } else { ItemData *data; - item = WAddMenuItemWithTitle(menu, title); - data = parseCommand(pi); - if (panel->markerPix[data->type]) - WSetEditMenuItemImage(item, panel->markerPix[data->type]); - WSetEditMenuItemData(item, data, (WMCallback *) freeItemData); + if (data != NULL) { + item = WAddMenuItemWithTitle(menu, title); + if (panel->markerPix[data->type]) + WSetEditMenuItemImage(item, panel->markerPix[data->type]); + WSetEditMenuItemData(item, data, (WMCallback *) freeItemData); + } else { + char *buf = wmalloc(1024); + snprintf(buf, 1024, _("Menu item \"%s\" removed:\nunknown command \"%s\""), + WMGetFromPLString(WMGetFromPLArray(pi, 0)), + WMGetFromPLString(WMGetFromPLArray(pi, 1))); + WMRunAlertPanel(scr, panel->parent, _("Warning"), buf, _("OK"), NULL, NULL); + wfree(buf); + } } } @@ -1639,7 +1642,7 @@ static WMPropList *processSubmenu(WEditMenu * menu) pmenu = WMCreatePLArray(pl, NULL); i = 0; - while ((item = WGetEditMenuItem(menu, i++))) { + while ((item = WGetEditMenuItem(menu, i++)) != NULL) { WEditMenu *submenu; s = WGetEditMenuItemTitle(item); -- 1.7.0.4 -- [-] mkdir /nonexistent -- To unsubscribe, send mail to [email protected].
