Instantiate j var outside #ifdef XINEMARA directive because it is used in loop outsid...
[dmenu.git] / dmenu.c
diff --git a/dmenu.c b/dmenu.c
index 91330f1..3c261c0 100644 (file)
--- a/dmenu.c
+++ b/dmenu.c
@@ -467,10 +467,12 @@ paste(void)
        Atom da;
 
        /* we have been given the current selection, now insert it into input */
-       XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
-                          utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
-       insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
-       XFree(p);
+       if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
+                          utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
+           == Success && p) {
+               insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
+               XFree(p);
+       }
        drawmenu();
 }
 
@@ -539,7 +541,7 @@ run(void)
 static void
 setup(void)
 {
-       int x, y, i = 0;
+       int x, y, i, j = 0;
        unsigned int du;
        XSetWindowAttributes swa;
        XIM xim;
@@ -549,9 +551,8 @@ setup(void)
 #ifdef XINERAMA
        XineramaScreenInfo *info;
        Window pw;
-       int a, j, di, n, area = 0;
+       int a, di, n, area = 0;
 #endif
-
        /* init appearance */
        for (j = 0; j < SchemeLast; j++)
                scheme[j] = drw_scm_create(drw, colors[j], 2);