1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Description: Correct export of environment variables
Author: Ludovic Brenta <ludovic@ludovic-brenta.org>,
Rebecca Palmer <rebecca_palmer@zoho.com>
Forwarded: http://sourceforge.net/p/flightgear/mailman/message/32689448/
--- a/src/run_posix.cxx
+++ b/src/run_posix.cxx
@@ -128,9 +128,20 @@
buf[0] = 0;
prefs.get( Fl_Preferences::Name("env-var-%d", i),
buf, "", buflen-1 );
- char* s = strdup( buf );
- putenv( s );
- free( s );
+ char *equals = strchr(buf, '=');
+ if (equals == NULL) {
+ /* environment variable name without a value; the value
+ follows */
+ unsetenv(buf);
+ }
+ else { /* value exists */
+ /* replace '=' with a new terminator; the value
+ follows */
+ *equals = '\0';
+ setenv(/* name: */ buf,
+ /* value: */ equals + 1,
+ /* overwrite: */ 1);
+ }
}
vector<string> argv;
argv.push_back( arg0 );
|