From 06170ca5e9402918b9412080a991a6fd76893857 Mon Sep 17 00:00:00 2001 From: throsturx Date: Wed, 29 Nov 2017 14:41:57 +0000 Subject: [PATCH] fixed a segfault on attempting to open a void selection in a newly opened terminal window --- termite.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/termite.cc b/termite.cc index ba1fc30..fb945ac 100644 --- a/termite.cc +++ b/termite.cc @@ -564,6 +564,13 @@ static void move_to_row_start(VteTerminal *vte, select_info *select, long row) { } static void open_selection(char *browser, VteTerminal *vte) { + // If the terminal has been opened, but no selection has ever been made + // , a segfault will occur upon attempting to make the unique pointer + // within vte_terminal_get_selection(vte) (unless if there is no browser). + if (!vte_terminal_get_has_selection(vte)) { + g_printerr("no selection to open\n"); + return + } if (browser) { auto selection = make_unique(vte_terminal_get_selection(vte), g_free); if (selection && *selection) {