From: Tony Crisci Date: Sun, 22 Mar 2015 09:46:52 +0000 (-0400) Subject: Bugfix: validation segfault X-Git-Tag: 4.10.1~37^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6fb7fc9bc64909a4ee86aabb71075ce04273b149;p=i3%2Fi3 Bugfix: validation segfault When `new_window` is given in the config, config validation with `i3 -C` would segfault. Add a NULL check in logical_px() to check for the case when the config is being validated without an X server to prevent this. --- diff --git a/libi3/dpi.c b/libi3/dpi.c index 37d5b215..6f58d57a 100644 --- a/libi3/dpi.c +++ b/libi3/dpi.c @@ -17,6 +17,12 @@ extern xcb_screen_t *root_screen; * */ int logical_px(const int logical) { + if (root_screen == NULL) { + /* Dpi info may not be available when parsing a config without an X + * server, such as for config file validation. */ + return logical; + } + const int dpi = (double)root_screen->height_in_pixels * 25.4 / (double)root_screen->height_in_millimeters; /* There are many misconfigurations out there, i.e. systems with screens