clipcopy: no need to check for free(NULL), set to NULL after free
[st.git] / x.c
diff --git a/x.c b/x.c
index 06e53d3..12bc86b 100644 (file)
--- a/x.c
+++ b/x.c
@@ -245,8 +245,8 @@ clipcopy(const Arg *dummy)
 {
        Atom clipboard;
 
-       if (xsel.clipboard != NULL)
-               free(xsel.clipboard);
+       free(xsel.clipboard);
+       xsel.clipboard = NULL;
 
        if (xsel.primary != NULL) {
                xsel.clipboard = xstrdup(xsel.primary);
@@ -1929,12 +1929,12 @@ main(int argc, char *argv[])
        } ARGEND;
 
 run:
-       if (argc > 0) {
-               /* eat all remaining arguments */
+       if (argc > 0) /* eat all remaining arguments */
                opt_cmd = argv;
-               if (!opt_title && !opt_line)
-                       opt_title = basename(xstrdup(argv[0]));
-       }
+
+       if (!opt_title)
+               opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
+
        setlocale(LC_CTYPE, "");
        XSetLocaleModifiers("");
        cols = MAX(cols, 1);