fix i3bar crashing when I3SOCK present (#2471)

When I3SOCK is present, socket_path might be a pointer to an
environment variable, which cannot be free'd in line 157. This
commit duplicates the string if I3SOCK is present, thus making
socket_path a free-able pointer again.
This commit is contained in:
koebi 2016-09-26 17:01:30 +02:00 committed by Michael Stapelberg
parent 23ee16077a
commit 655ed0ba27
1 changed files with 3 additions and 0 deletions

View File

@ -93,6 +93,9 @@ int main(int argc, char **argv) {
int opt; int opt;
int option_index = 0; int option_index = 0;
char *socket_path = getenv("I3SOCK"); char *socket_path = getenv("I3SOCK");
if (socket_path != NULL) {
socket_path = sstrdup(socket_path);
}
char *i3_default_sock_path = "/tmp/i3-ipc.sock"; char *i3_default_sock_path = "/tmp/i3-ipc.sock";
/* Initialize the standard config to use 0 as default */ /* Initialize the standard config to use 0 as default */