commit c641c79a7002c53a0ef113864234a8f51ee0fcc4 parent aa7f57eed805adb09e9c59c8ea841870e8206b81 Author: Fangrui Song <i@maskray.me> Date: Sun, 4 Dec 2016 23:31:06 -0800 Fix #19 segfault when --append to empty selection Diffstat:
M | xsel.c | | | 12 | ++++++------ |
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/xsel.c b/xsel.c @@ -834,12 +834,12 @@ get_selection_text (Atom selection) static unsigned char * copy_sel (unsigned char * s) { - unsigned char * new_sel = NULL; - - new_sel = xs_strdup (s); - current_alloc = total_input = xs_strlen (s); - - return new_sel; + if (s) { + current_alloc = total_input = xs_strlen (s); + return xs_strdup (s); + } + current_alloc = total_input = 0; + return NULL; } /*