commit 095f539bbb36a47f2492d036947233b1c915e055
parent 95747b1a8ef7e093b7c9fcf51e4e4796316ab811
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date: Mon, 29 Mar 2021 22:31:46 +0200
Fix bug when fgets exits with error
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dwmblocks.c b/dwmblocks.c
@@ -60,7 +60,8 @@ void getcmd(const Block *block, char *output)
FILE *cmdf = popen(block->command, "r");
if (!cmdf)
return;
- fgets(output, CMDLENGTH-strlen(delim), cmdf);
+ if (fgets(output, CMDLENGTH-strlen(delim), cmdf) == NULL)
+ output[0] = '\0';
pclose(cmdf);
i = strlen(output);