]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: reset parser state in `menu_finish()`
authortokyo4j <hrak1529@gmail.com>
Sun, 5 May 2024 09:41:10 +0000 (18:41 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 5 May 2024 10:49:39 +0000 (12:49 +0200)
This fixes use-after-free in `fill_item()` on Reconfigure with
invalid `menu.xml` like below:

<openbox_menu>
  <menu id="root-menu">
    <item id="rofi-run" label="Run command">
      <action name="Execute" command="rofi-run" />
    </item>
  </menu>
</openbox_menu>

src/menu/menu.c

index 84b8679353554b21c0beb6e7fda389f3e3ae3864..064c803bdd5123095d884d3ececd9cd4208b5c94 100644 (file)
@@ -960,6 +960,11 @@ void
 menu_finish(struct server *server)
 {
        menu_free_from(server, NULL);
+
+       /* Reset state vars for starting fresh when Reload is triggered */
+       current_item = NULL;
+       current_item_action = NULL;
+       current_menu = NULL;
 }
 
 /* Sets selection (or clears selection if passing NULL) */