aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-17 21:43:24 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-17 21:43:24 (GMT)
commit87b45bd0d18323898d5c09bb7cad7566e3267635 (patch)
treef5570d524399e3dab443dde9419af86c3874f416 /src/main.cc
parentf3ad09c4ce70cc58871eeac49d640f213f3cd16f (diff)
downloadfluxbox-87b45bd0d18323898d5c09bb7cad7566e3267635.zip
fluxbox-87b45bd0d18323898d5c09bb7cad7566e3267635.tar.bz2
bugfix: avoid naive use of 'putenv' by providing 'FbTk::App::setenv()'
to quote from 'man putenv': The string pointed to by string becomes part of the environment, so altering the string changes the environment. so, using putenv like { std::string foo("FOO=bar"); putenv(foo.c_str()); } is wrong and leads to a potentially corrupted environment. valgrind complaint correctly. FbTk::App seems to be the appropriate place to hold '::seten()' because it alters the environment of the application.
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/main.cc b/src/main.cc
index 300826e..28302d4 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -219,8 +219,7 @@ static void parseOptions(int argc, char** argv, Options& opts) {
219 } 219 }
220 220
221 opts.session_display = argv[i]; 221 opts.session_display = argv[i];
222 string display_env = "DISPLAY=" + opts.session_display; 222 if (!FbTk::App::setenv("DISPLAY", argv[i])) {
223 if (putenv(const_cast<char *>(display_env.c_str()))) {
224 cerr<<_FB_CONSOLETEXT(main, WarnDisplayEnv, 223 cerr<<_FB_CONSOLETEXT(main, WarnDisplayEnv,
225 "warning: couldn't set environment variable 'DISPLAY'", 224 "warning: couldn't set environment variable 'DISPLAY'",
226 "")<<endl; 225 "")<<endl;