]> Dogcows Code - chaz/openbox/blobdiff - openbox/menuframe.c
fix for using freed memory to exec stuff
[chaz/openbox] / openbox / menuframe.c
index 053034b3869a783ddae60bfb6821447368e4e4f1..725b1a18b732047284a392a1e436cab57a8dbc90 100644 (file)
@@ -572,16 +572,22 @@ void menu_entry_frame_show_submenu(ObMenuEntryFrame *self)
 void menu_entry_frame_execute(ObMenuEntryFrame *self, gboolean hide)
 {
     if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) {
+        /* grab all this shizzle, cuz when the menu gets hidden, 'self'
+           gets freed */
+        ObMenuEntry *entry = self->entry;
+        ObMenuExecuteFunc func = self->frame->menu->execute_func;
+        gpointer data = self->frame->menu->data;
+        GSList *acts = self->entry->data.normal.actions;
+
         /* release grabs before executing the shit */
         menu_frame_hide_all();
 
-        if (self->frame->menu->execute_func)
-            self->frame->menu->execute_func(self, self->frame->menu->data);
+        if (func)
+            func(entry, data);
         else {
             GSList *it;
 
-            for (it = self->entry->data.normal.actions; it;
-                 it = g_slist_next(it))
+            for (it = acts; it; it = g_slist_next(it))
             {
                 ObAction *act = it->data;
                 act->data.any.c = self->frame->client;
This page took 0.026394 seconds and 4 git commands to generate.