[hackers] [wmii] Prevent segfault when initdisplay() can't open a Display.

From: sqweek <sqweek_AT_gmail.com>
Date: Tue Oct 02 17:36:51 2007

changeset: 2214:0a39783b3e3c
tag: tip
user: sqweek <sqweek_AT_gmail.com>
date: Tue Oct 02 22:49:58 2007 +0800
summary: Prevent segfault when initdisplay() can't open a Display.

diff -r e7085e32d2fe -r 0a39783b3e3c cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Tue Oct 02 22:38:42 2007 +0800
+++ b/cmd/wmii/x11.c Tue Oct 02 22:49:58 2007 +0800
@@ -122,7 +122,8 @@ Wfmt(Fmt *f) {
 /* Init */
 void
 initdisplay(void) {
- display = XOpenDisplay(nil);
+ if(!(display = XOpenDisplay(nil)))
+ fatal("couldn't open display");
         scr.screen = DefaultScreen(display);
         scr.colormap = DefaultColormap(display, scr.screen);
         scr.visual = DefaultVisual(display, scr.screen);
Received on Tue Oct 02 2007 - 17:36:51 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:58:27 UTC