diff --git a/xsel.c b/xsel.c index 0dd9bd4..5c1b57e 100644 --- a/xsel.c +++ b/xsel.c @@ -2344,7 +2344,7 @@ main(int argc, char *argv[]) if(trim_trailing_newline) { unsigned int sel_len = xs_strlen(new_sel); - if (new_sel[sel_len - 1 ] == '\n') { + if (sel_len && new_sel[sel_len - 1 ] == '\n') { new_sel[sel_len - 1] = '\0'; } }