From: shdown Date: Thu, 20 Aug 2015 19:55:23 +0000 (+0300) Subject: i3-msg: strdup getenv() result before freeing X-Git-Tag: 4.11~46^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F1853%2Fhead;p=i3%2Fi3 i3-msg: strdup getenv() result before freeing Fixes #1852. --- diff --git a/i3-msg/main.c b/i3-msg/main.c index 47e7ae91..e4a0628c 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;