]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/demo_menus.c
ncurses 5.9 - patch 20121117
[ncurses.git] / test / demo_menus.c
index 8f19281dfa6945d06119cfbfabac1d8b983b5aa8..dd1bd4fcbc31c11e60535a6ec465e7121e9a9c6f 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_menus.c,v 1.36 2012/11/03 19:27:01 tom Exp $
+ * $Id: demo_menus.c,v 1.37 2012/11/18 00:18:54 tom Exp $
  *
  * Demonstrate a variety of functions from the menu library.
  * Thomas Dickey - 2005/4/9
  *
  * Demonstrate a variety of functions from the menu library.
  * Thomas Dickey - 2005/4/9
@@ -269,12 +269,15 @@ menu_destroy(MENU * m)
                free((char *) blob);
            }
            free(items);
                free((char *) blob);
            }
            free(items);
+           items = 0;
        }
 #ifdef TRACE
        if ((count > 0) && (m == mpTrace)) {
            ITEM **ip = items;
        }
 #ifdef TRACE
        if ((count > 0) && (m == mpTrace)) {
            ITEM **ip = items;
-           while (*ip)
-               free(*ip++);
+           if (ip != 0) {
+               while (*ip)
+                   free(*ip++);
+           }
        }
 #endif
     }
        }
 #endif
     }
@@ -386,6 +389,8 @@ build_select_menu(MenuNo number, char *filename)
                }
                loaded_file = TRUE;
            }
                }
                loaded_file = TRUE;
            }
+           if (ap == 0)
+               free(items);
        }
     }
     if (ap == 0) {
        }
     }
     if (ap == 0) {