X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fconfig_parser.c;h=9f972fed8f80b4510931cac6edb52cef431c832a;hb=eedb25765590460d328f42364cc2396a6fcd9f0e;hp=9d8369c80e46e2b9e1d4503644a717bd0acbaaac;hpb=962750eb64c7f968a03c4f57541d864f2418fcaf;p=i3%2Fi3 diff --git a/src/config_parser.c b/src/config_parser.c index 9d8369c8..9f972fed 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -171,7 +171,7 @@ static long get_long(const char *identifier) { static void clear_stack(void) { for (int c = 0; c < 10; c++) { - if (stack[c].type == STACK_STR && stack[c].val.str != NULL) + if (stack[c].type == STACK_STR) free(stack[c].val.str); stack[c].identifier = NULL; stack[c].val.str = NULL; @@ -743,7 +743,7 @@ static char *migrate_config(char *input, off_t size) { /* read the script’s output */ int conv_size = 65535; - char *converted = smalloc(conv_size); + char *converted = scalloc(conv_size, 1); int read_bytes = 0, ret; do { if (read_bytes == conv_size) { @@ -902,7 +902,9 @@ bool parse_file(const char *f, bool use_nagbar) { FREE(current_config); current_config = scalloc(stbuf.st_size + 1, 1); - fread(current_config, 1, stbuf.st_size, fstr); + if ((ssize_t)fread(current_config, 1, stbuf.st_size, fstr) != stbuf.st_size) { + die("Could not fread: %s\n", strerror(errno)); + } rewind(fstr); bool invalid_sets = false; @@ -1063,7 +1065,7 @@ bool parse_file(const char *f, bool use_nagbar) { int version = detect_version(buf); if (version == 3) { /* We need to convert this v3 configuration */ - char *converted = migrate_config(new, stbuf.st_size); + char *converted = migrate_config(new, strlen(new)); if (converted != NULL) { ELOG("\n"); ELOG("****************************************************************\n");