From bc311b7ae68437ed2d300944cf5639dc5520ca28 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Wed, 5 Nov 2008 19:36:58 +0100 Subject: [PATCH] conf: Fix segfault when you remove one of any layouts in the conf file --- src/config.c | 9 +++++---- src/structs.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 320823e..10cabc3 100644 --- a/src/config.c +++ b/src/config.c @@ -135,11 +135,11 @@ char_to_button(char *name) } Layout -layout_name_to_struct(Layout lt[], char *name) +layout_name_to_struct(Layout lt[], char *name, int n) { int i; - for(i = 0; i < NUM_OF_LAYOUT; ++i) + for(i = 0; i < n; ++i) if(lt[i].func == name_to_func(name, layout_list)) return lt[i]; @@ -469,6 +469,7 @@ init_conf(void) } } + /* tag */ /* if there is no tag in the conf or more than * MAXTAG (32) print an error and create only one. */ @@ -487,7 +488,7 @@ init_conf(void) conf.tag[0].mwfact = 0.65; conf.tag[0].nmaster = 1; conf.tag[0].resizehint = False; - conf.tag[0].layout = layout_name_to_struct(conf.layout, "tile"); + conf.tag[0].layout = layout_name_to_struct(conf.layout, "tile", conf.nlayout); } else { @@ -500,7 +501,7 @@ init_conf(void) conf.tag[i].mwfact = cfg_getfloat(cfgtmp, "mwfact"); conf.tag[i].nmaster = cfg_getint(cfgtmp, "nmaster"); conf.tag[i].resizehint = cfg_getbool(cfgtmp, "resizehint"); - conf.tag[i].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout")); + conf.tag[i].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout"), conf.nlayout); } } diff --git a/src/structs.h b/src/structs.h index f9f7308..7b12e95 100644 --- a/src/structs.h +++ b/src/structs.h @@ -39,7 +39,6 @@ #define MAXTAG 36 #define NUM_OF_LAYOUT 7 -#define NUM_OF_TILE 5 /* Typedef */ typedef const char* uicb_t;