commit 2177aed027e2f87ac491347ad3809dae92d36787
parent 0855f12de83ba41bb5376811e00cf7606aed4723
Author: Kris Maglione <kris@suckless.org>
Date: Mon, 21 Jun 2010 10:29:51 -0400
Make sure a window has a visual before dereferencing it. Fixes issue #195.
Diffstat:
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/libstuff/x11/colors/parsecolor.c b/lib/libstuff/x11/colors/parsecolor.c
@@ -7,7 +7,7 @@ ulong
pixelvalue(Window *w, Color *c) {
XColor xc;
- if(w->visual->class != TrueColor) {
+ if(w->visual == nil || w->visual->class != TrueColor) {
if(c->pixel != ~0UL)
return c->pixel;
xc.red = c->red;
diff --git a/lib/libstuff/x11/initdisplay.c b/lib/libstuff/x11/initdisplay.c
@@ -68,6 +68,7 @@ initdisplay(void) {
scr.depth = DefaultDepth(display, scr.screen);
scr.root.xid = RootWindow(display, scr.screen);
+ scr.root.visual = scr.visual;
scr.root.r = Rect(0, 0,
DisplayWidth(display, scr.screen),
DisplayHeight(display, scr.screen));