]> git.armaanb.net Git - dwmblocks.git/commitdiff
Fixes #9 - determine the size of the status buffer based on the number of blocks
authorTom Böhmer <qtom.boehmer@googlemail.com>
Thu, 28 May 2020 08:39:07 +0000 (10:39 +0200)
committerTom Böhmer <qtom.boehmer@googlemail.com>
Thu, 28 May 2020 16:25:26 +0000 (18:25 +0200)
prevents dwmblocks from crashing because of the status string getting
longer than the underlying buffer

dwmblocks.c

index 2f3b774664cfca6eac7e016b946b1eed3088f9cf..3af799f751cedaf21970f46ac2456bcb05f0e484 100644 (file)
@@ -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;