diff --git a/control.c b/control.c index 2fc97b5e..5076a5f7 100644 --- a/control.c +++ b/control.c @@ -207,10 +207,12 @@ control_free_sub(struct control_state *cs, struct control_sub *csub) RB_FOREACH_SAFE(csp, control_sub_panes, &csub->panes, csp1) { RB_REMOVE(control_sub_panes, &csub->panes, csp); + free(csp->last); free(csp); } RB_FOREACH_SAFE(csw, control_sub_windows, &csub->windows, csw1) { RB_REMOVE(control_sub_windows, &csub->windows, csw); + free(csw->last); free(csw); } free(csub->last); diff --git a/mode-tree.c b/mode-tree.c index bf0b163c..6479d78d 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -301,6 +301,8 @@ mode_tree_clear_tagged(struct mode_tree_list *mtl) void mode_tree_up(struct mode_tree_data *mtd, int wrap) { + if (mtd->line_size == 0) + return; if (mtd->current == 0) { if (wrap) { mtd->current = mtd->line_size - 1; @@ -317,6 +319,8 @@ mode_tree_up(struct mode_tree_data *mtd, int wrap) int mode_tree_down(struct mode_tree_data *mtd, int wrap) { + if (mtd->line_size == 0) + return (0); if (mtd->current == mtd->line_size - 1) { if (wrap) { mtd->current = 0; @@ -363,6 +367,8 @@ mode_tree_swap(struct mode_tree_data *mtd, int direction) void * mode_tree_get_current(struct mode_tree_data *mtd) { + if (mtd->line_size == 0) + return (NULL); return (mtd->line_list[mtd->current].item->itemdata); } @@ -433,6 +439,8 @@ mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) return (1); } if (mtd->current >= mtd->line_size) { + if (mtd->line_size == 0) + return (0); mtd->current = mtd->line_size - 1; if (mtd->current > mtd->height - 1) mtd->offset = mtd->current - mtd->height + 1;