]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/main.c
fix i3bar crashing when I3SOCK present (#2471)
[i3/i3] / i3bar / src / main.c
index a9a972dbe6c12a37a5893b830bf7244b5ef34bca..14e42a2bf425f9ec72a4689905ed0b145e9efc37 100644 (file)
@@ -2,7 +2,7 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3bar - an xcb-based status- and ws-bar for i3
- * © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
+ * © 2010 Axel Wagner and contributors (see also: LICENSE)
  *
  */
 #include <stdio.h>
@@ -93,6 +93,9 @@ int main(int argc, char **argv) {
     int opt;
     int option_index = 0;
     char *socket_path = getenv("I3SOCK");
+    if (socket_path != NULL) {
+        socket_path = sstrdup(socket_path);
+    }
     char *i3_default_sock_path = "/tmp/i3-ipc.sock";
 
     /* Initialize the standard config to use 0 as default */
@@ -111,7 +114,7 @@ int main(int argc, char **argv) {
                 socket_path = expand_path(optarg);
                 break;
             case 'v':
-                printf("i3bar version " I3_VERSION " © 2010-2014 Axel Wagner and contributors\n");
+                printf("i3bar version " I3_VERSION " © 2010 Axel Wagner and contributors\n");
                 exit(EXIT_SUCCESS);
                 break;
             case 'b':
@@ -137,6 +140,8 @@ int main(int argc, char **argv) {
 
     if (socket_path == NULL) {
         socket_path = atom_sock_path;
+    } else {
+        free(atom_sock_path);
     }
 
     if (socket_path == NULL) {
@@ -149,6 +154,7 @@ int main(int argc, char **argv) {
         /* Request the bar configuration. When it arrives, we fill the config array. */
         i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG, config.bar_id);
     }
+    free(socket_path);
 
     /* We listen to SIGTERM/QUIT/INT and try to exit cleanly, by stopping the main loop.
      * We only need those watchers on the stack, so putting them on the stack saves us