shithub: orca

Download patch

ref: 8b4a3bb6919f5ce3a6c27774e489d48be91d5ae7
parent: 615e53ecabc66c8a5f9a74ed74415d4600bfabc5
author: cancel <cancel@cancel.fm>
date: Sun Jan 5 20:22:19 EST 2020

Add freeing of owned strings in qmenu items

--- a/term_util.c
+++ b/term_util.c
@@ -449,8 +449,16 @@
 void qmenu_free(Qmenu* qm) {
   unpost_menu(qm->ncurses_menu);
   free_menu(qm->ncurses_menu);
+  struct Qmenu_item_extra* extras = qmenu_item_extras_ptr(qm);
   for (Usz i = 0; i < qm->items_count; ++i) {
+    ITEM* item = qm->ncurses_items[i];
+    struct Qmenu_item_extra* extra = qmenu_itemextra(extras, item);
+    char const* freed_str = NULL;
+    if (extra->owns_string)
+      freed_str = item_name(item);
     free_item(qm->ncurses_items[i]);
+    if (freed_str)
+      free((void*)freed_str);
   }
   free(qm->ncurses_items);
   free(qm);