From: Thierry Lorthiois Date: Tue, 8 Jun 2010 15:56:04 +0000 (+0000) Subject: fixed segfault with monitor detection X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Ftint2;a=commitdiff_plain;h=106a3423e2a034da08b6f12c87b42b9a99fb34af fixed segfault with monitor detection --- diff --git a/src/config.c b/src/config.c index 61178d1..6233ecc 100644 --- a/src/config.c +++ b/src/config.c @@ -155,9 +155,7 @@ int get_task_status(char* status) int config_get_monitor(char* monitor) { - if (strcmp(monitor, "all") == 0) - return -1; - else { + if (strcmp(monitor, "all") != 0) { char* endptr; int ret_int = strtol(monitor, &endptr, 10); if (*endptr == 0) @@ -166,6 +164,9 @@ int config_get_monitor(char* monitor) // monitor specified by name, not by index int i, j; for (i=0; incrtc >= nbmonitor) { + if (res && res->ncrtc >= nbmonitor) { // use xrandr to identify monitors (does not work with proprietery nvidia drivers) printf("xRandr: Found crtc's: %d\n", res->ncrtc ); server.monitor = malloc(res->ncrtc * sizeof(Monitor)); @@ -307,7 +307,8 @@ next: server.monitor = realloc(server.monitor, server.nb_monitor * sizeof(Monitor)); qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitorPos); - XRRFreeScreenResources(res); + if (res) + XRRFreeScreenResources(res); XFree(info); }