From 44a708b7a4a266ca8e91eb8a6a1b34ffa4a7a164 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 22 May 2016 15:31:42 +0200 Subject: [PATCH] Don't use optarg directly when parsing the -n switch argument. --- lemonbar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lemonbar.c b/lemonbar.c index c31cb26..36fbfb7 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -1,4 +1,5 @@ // vim:sw=4:ts=4:et: +#define _POSIX_C_SOURCE 200809L #include #include #include @@ -1303,7 +1304,7 @@ main (int argc, char **argv) exit (EXIT_SUCCESS); case 'g': (void)parse_geometry_string(optarg, geom_v); break; case 'p': permanent = true; break; - case 'n': wm_name = optarg; break; + case 'n': wm_name = strdup(optarg); break; case 'b': topbar = false; break; case 'd': dock = true; break; case 'f': font_load(optarg); break; @@ -1338,6 +1339,8 @@ main (int argc, char **argv) // Do the heavy lifting init(wm_name); + // The string is strdup'd when the command line arguments are parsed + free(wm_name); // Get the fd to Xserver pollin[1].fd = xcb_get_file_descriptor(c);