chiark / gitweb /
Some configuration-related memory hygeine.
[disorder] / clients / disorder.c
index 1d55b8db6a7f14eedba2f555e69a5e13872dfb88..298494a9befa8bca4eaa2929a90f78e2e63c475f 100644 (file)
@@ -864,11 +864,14 @@ int main(int argc, char **argv) {
   }
   if(config_read(0, NULL)) disorder_fatal(0, "cannot read configuration");
   if(user) {
-    config->username = user;
+    xfree(config->username);
+    config->username = xstrdup(user);
     config->password = 0;
   }
-  if(password)
-    config->password = password;
+  if(password) {
+    xfree(config->password);
+    config->password = xstrdup(password);
+  }
   if(local)
     config->connect.af = -1;
   if(wfr)
@@ -899,10 +902,12 @@ int main(int argc, char **argv) {
       vector_append(&args, nullcheck(mb2utf8(argv[n + j])));
     vector_terminate(&args);
     commands[i].fn(args.vec + 1);
+    xfree(args.vec);
     n += j;
   }
   if(client && disorder_close(client)) exit(EXIT_FAILURE);
   if(fclose(stdout) < 0) disorder_fatal(errno, "error closing stdout");
+  config_free(config);
   return status;
 }