Tags: patch

hi,
i have identified a bug and make a patch to solve it.

problem:
dangling pointer in menu.cc setShellCmdMenu(),val will be dangling pointer
after every loop time.

fix:
by adding std::string cmd like std::string label

the patch is attached. please consider applying it.

thank
zixgggg
Description:fix usermenu can not run command from miwm.usermenu ,
 problem is dangling pointer in menu.cc setShellCmdMenu(),
 val will be dangling pointer after every loop time.
 .
 fix way by adding std::string cmd like std::string label

Author:zixgggg <[email protected]>
Bug-Debian:https://bugs.debian.org/1153016

diff --git a/menu.cc b/menu.cc
index ac7aacf..b4cbe3d 100644
--- a/menu.cc
+++ b/menu.cc
@@ -261,7 +261,7 @@ Menu::buttonRelease() {
       break;

     case commandMenu:
-      theWM->spawn((char*) currMI->data);
+      theWM->spawn((char*) currMI->cmd.c_str());
       break;

     default:
@@ -535,7 +535,7 @@ WindowManager::setShellCmdMenu() {
                 if( val.empty() ) { ++it; continue; } // no point, is there?
                 mi = new MenuItem();
                 mi->label = (*it);
-                mi->data = (const void *)  val.c_str();
+                mi->cmd = val.c_str();
                 menu->items->append((void*) mi);
                 ++it;
         }
diff --git a/mimenu.h b/mimenu.h
index b208429..676d595 100644
--- a/mimenu.h
+++ b/mimenu.h
@@ -86,6 +86,7 @@ public:
   ~MenuItem();

   std::string label;
+  std::string cmd;
   const void* data; // Client*, WorkSpace*, etc.

 protected:

Reply via email to