From: Andreas Fink Date: Tue, 5 Jan 2010 11:24:48 +0000 (+0000) Subject: *fix* once again issue 192 X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=0063d936c925d1be1eac389f710dfc65460f5520;p=chaz%2Ftint2 *fix* once again issue 192 --- diff --git a/src/config.c b/src/config.c index 69ceda0..62a8c58 100644 --- a/src/config.c +++ b/src/config.c @@ -287,7 +287,7 @@ void add_entry (char *key, char *value) panel_config.g_task.font_shadow = atoi (value); else if (strcmp (key, "panel_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.area.pix.border, &a->pix.border, sizeof(Border)); @@ -361,7 +361,7 @@ void add_entry (char *key, char *value) else if (strcmp (key, "battery_background_id") == 0) { #ifdef ENABLE_BATTERY int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.battery.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.battery.area.pix.border, &a->pix.border, sizeof(Border)); @@ -407,7 +407,7 @@ void add_entry (char *key, char *value) } else if (strcmp (key, "clock_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.clock.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.clock.area.pix.border, &a->pix.border, sizeof(Border)); @@ -442,14 +442,14 @@ void add_entry (char *key, char *value) } else if (strcmp (key, "taskbar_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.g_taskbar.pix.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.g_taskbar.pix.border, &a->pix.border, sizeof(Border)); } else if (strcmp (key, "taskbar_active_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.g_taskbar.pix_active.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.g_taskbar.pix_active.border, &a->pix.border, sizeof(Border)); @@ -510,14 +510,14 @@ void add_entry (char *key, char *value) } else if (strcmp (key, "task_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.g_task.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.g_task.area.pix.border, &a->pix.border, sizeof(Border)); } else if (strcmp (key, "task_active_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&panel_config.g_task.area.pix_active.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config.g_task.area.pix_active.border, &a->pix.border, sizeof(Border)); @@ -539,7 +539,7 @@ void add_entry (char *key, char *value) } else if (strcmp (key, "systray_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border)); @@ -582,7 +582,7 @@ void add_entry (char *key, char *value) } else if (strcmp (key, "tooltip_background_id") == 0) { int id = atoi (value); - id = id < back_count ? id : 0; + id = (id < back_count && id >= 0) ? id : 0; Area *a = g_slist_nth_data(list_back, id); memcpy(&g_tooltip.background_color, &a->pix.back, sizeof(Color)); memcpy(&g_tooltip.border, &a->pix.border, sizeof(Border));