menu: reset parser state in menu_finish()

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>
This commit is contained in:
tokyo4j 2024-05-05 18:41:10 +09:00 committed by Consolatis
parent 8d4f295440
commit 95dc4ac4b5

View file

@ -960,6 +960,11 @@ void
menu_finish(struct server *server) menu_finish(struct server *server)
{ {
menu_free_from(server, NULL); 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) */ /* Sets selection (or clears selection if passing NULL) */