diff options
author | Tom Böhmer <qtom.boehmer@googlemail.com> | 2020-05-28 10:39:07 +0200 |
---|---|---|
committer | Tom Böhmer <qtom.boehmer@googlemail.com> | 2020-05-28 18:25:26 +0200 |
commit | 4d92b6ca6caae215a79f00d88404c018b9eac15f (patch) | |
tree | 76d3e4dc664292b939432794252fd6674993bf63 | |
parent | 6e0519df3aeba97276d18a8e4bb7d41df675634c (diff) |
Fixes #9 - determine the size of the status buffer based on the number of blocks
prevents dwmblocks from crashing because of the status string getting
longer than the underlying buffer
-rw-r--r-- | dwmblocks.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/dwmblocks.c b/dwmblocks.c index 2f3b774..3af799f 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -6,6 +6,7 @@ #include<X11/Xlib.h> #define LENGTH(X) (sizeof(X) / sizeof (X[0])) #define CMDLENGTH 50 +#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1) typedef struct { char* icon; @@ -32,7 +33,7 @@ static Display *dpy; static int screen; static Window root; static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; -static char statusstr[2][256]; +static char statusstr[2][STATUSLENGTH]; static int statusContinue = 1; static void (*writestatus) () = setroot; |