From: Michael Stapelberg Date: Sun, 20 Aug 2017 10:55:55 +0000 (+0200) Subject: (Re-)initialize optional fields to empty strings X-Git-Tag: 4.14~10^2~4 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dd019f59fa3e2935a29d7ad4c24020eb589e12c4;p=i3%2Fi3 (Re-)initialize optional fields to empty strings --- diff --git a/src/config_parser.c b/src/config_parser.c index c3684737..0fcdeb6e 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -916,6 +916,7 @@ bool parse_file(const char *f, bool use_nagbar) { } /* sscanf implicitly strips whitespace. */ + value[0] = '\0'; const bool skip_line = (sscanf(buffer, "%511s %4095[^\n]", key, value) < 1 || strlen(key) < 3); const bool comment = (key[0] == '#'); value[4095] = '\n'; @@ -938,7 +939,7 @@ bool parse_file(const char *f, bool use_nagbar) { if (strcasecmp(key, "set") == 0) { char v_key[512]; - char v_value[4096]; + char v_value[4096] = {'\0'}; if (sscanf(value, "%511s %4095[^\n]", v_key, v_value) < 1) { ELOG("Failed to parse variable specification '%s', skipping it.\n", value); @@ -953,9 +954,9 @@ bool parse_file(const char *f, bool use_nagbar) { upsert_variable(&variables, v_key, v_value); continue; } else if (strcasecmp(key, "set_from_resource") == 0) { - char res_name[512]; + char res_name[512] = {'\0'}; char v_key[512]; - char fallback[4096]; + char fallback[4096] = {'\0'}; /* Ensure that this string is terminated. For example, a user might * want a variable to be empty if the resource can't be found and