]> git.sur5r.net Git - i3/i3/commitdiff
i3-msg: strdup getenv() result before freeing
authorshdown <shdownnine@gmail.com>
Thu, 20 Aug 2015 19:55:23 +0000 (22:55 +0300)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 8 Sep 2015 07:13:26 +0000 (09:13 +0200)
Fixes #1852.

i3-msg/main.c

index 354e8af90d61b0b939cbb7d241a0ac8a53cd2ebe..238fe15237e01b11a253a9cc10e8069686f7d884 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;