File: export-env.diff

package info (click to toggle)
fgrun 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,352 kB
  • ctags: 701
  • sloc: cpp: 7,615; sh: 507; makefile: 26; ansic: 8
file content (30 lines) | stat: -rw-r--r-- 928 bytes parent folder | download
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 );