]> git.sur5r.net Git - i3/i3/commitdiff
i3-msg: strdup getenv() result before freeing 1853/head
authorshdown <shdownnine@gmail.com>
Thu, 20 Aug 2015 19:55:23 +0000 (22:55 +0300)
committershdown <shdownnine@gmail.com>
Thu, 20 Aug 2015 20:07:41 +0000 (23:07 +0300)
Fixes #1852.

i3-msg/main.c

index 47e7ae91e681e583f039d31b4e1ce83654fe44c4..e4a0628c9db985465c5c1f425fa38c5d40d5ac5a 100644 (file)
@@ -119,7 +119,11 @@ static yajl_callbacks reply_callbacks = {
 };
 
 int main(int argc, char *argv[]) {
-    socket_path = getenv("I3SOCK");
+    char *env_socket_path = getenv("I3SOCK");
+    if (env_socket_path)
+        socket_path = sstrdup(env_socket_path);
+    else
+        socket_path = NULL;
     int o, option_index = 0;
     uint32_t message_type = I3_IPC_MESSAGE_TYPE_COMMAND;
     char *payload = NULL;