]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #3076 from orestisf1993/v3-to-v4-issue
authorIngo Bürk <admin@airblader.de>
Sat, 9 Dec 2017 18:42:30 +0000 (19:42 +0100)
committerGitHub <noreply@github.com>
Sat, 9 Dec 2017 18:42:30 +0000 (19:42 +0100)
minor V3 to v4 issues

src/config_parser.c
testcases/t/183-config-variables.t

index 4e66c91109f3f8f37d0dfddbeacc2da6545cb23c..2d3f3bb919eb2d134baa61f9e510880275fd8210 100644 (file)
@@ -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) {
@@ -1065,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");
index 4b225214addca64097047ac2722408fb18395ebe..d135ed59ccf145f42beacce4ebf2f26357abd32e 100644 (file)
@@ -95,7 +95,19 @@ EOT
 
 is(launch_get_border($config), 'none', 'no border');
 
+#####################################################################
+# test that variables with longer name than value don't crash i3 with
+# v3 to v4 conversion.
+# See: #3076
+#####################################################################
+
+$config = <<'EOT';
+set $var a
+EOT
 
+my $pid = launch_with_config($config);
+does_i3_live;
+exit_gracefully($pid);
 
 done_testing;