From f8d8acd93c74a346ef335154b15b50c016667b23 Mon Sep 17 00:00:00 2001 From: shdown Date: Thu, 20 Aug 2015 22:55:23 +0300 Subject: [PATCH] i3-msg: strdup getenv() result before freeing Fixes #1852. --- i3-msg/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/i3-msg/main.c b/i3-msg/main.c index 354e8af9..238fe152 100644 --- a/i3-msg/main.c +++ b/i3-msg/main.c @@ -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; -- 2.39.5