On Fri, 17 Sep 2010, Carlos R. Mafra wrote:

 > Perhaps it's some effect of the wine now, but the patch does
 > not apply. 

how about this then - i did a fresh checkout.

>From bcb91effd7a16938aba195ecb6f0bbcb8eab5dc0 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Sat, 18 Sep 2010 15:52:47 +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.

Signed-off-by: Tamas TEVESZ <[email protected]>
---
 WPrefs.app/Menu.c |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c
index dccb85b..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";
@@ -1030,7 +1030,8 @@ static ItemData *parseCommand(WMPropList * item)
                        cmd = 11;
                } else {
                        wwarning(_("unknown command '%s' in menu"), command);
-                       goto error;
+                       wfree(data);
+                       return NULL;
                }
 
                data->type = CommandInfo;
@@ -1043,11 +1044,6 @@ static ItemData *parseCommand(WMPropList * item)
        }
 
        return data;
-
- error:
-       wfree(data);
-
-       return NULL;
 }
 
 static void updateFrameTitle(_Panel * panel, char *title, InfoType type)
@@ -1396,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);
+                       }
                }
        }
 
@@ -1638,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].

Reply via email to