usrlib.de / CVS

Diff for revision 1.22 of bgset/bgset.c

--- //cvs/lukas/bgset/bgset.c	2017/03/29 14:47:21	1.21
+++ //cvs/lukas/bgset/bgset.c	2017/03/30 01:41:42	1.22
@@ -138,9 +138,12 @@
 	XGetWindowProperty(dpy, root, pxm_prop, 0L, 1L, False,
 	    AnyPropertyType, &type, &format, &nitems, &bytes_after, &data);
 	if (data) {
-		if (type == XA_PIXMAP) {
-			pxm = *((Pixmap *) data);
+		if (type != XA_PIXMAP) {
+			warnx("_XROOTPMAP_ID is not a pixmap.");
+			XFree(data);
+			return 0;
 		}
+		pxm = *((Pixmap *) data);
 		XFree(data);
 		/* reset if screen geometry has changed */
 		XGetGeometry(dpy, pxm, &root, &px_x, &px_y, &px_w, &px_h,
@@ -273,7 +276,10 @@
 
 	/* initialize */
 	x_init(&dpy, &scr, &info, &scrnum);
-	pxm = init_root_pixmap(dpy, scr);
+	if (!(pxm = init_root_pixmap(dpy, scr))) {
+		ret = 2;
+		goto finish;
+	}
 
 	/* draw images */
 	i = 0;