Merge pull request #3395 from lambdageek/dev/handles-strings
[mono.git] / mcs / class / corlib / System / Environment.cs
index 9d83a457795eed417d8203cefc25a8a588736a86..36ae8687aae76a3cf40e67ae5f76c4dc32993fed 100644 (file)
@@ -472,7 +472,15 @@ namespace System {
                public extern static string[] GetCommandLineArgs ();
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               internal extern static string internalGetEnvironmentVariable (string variable);
+               internal extern static string internalGetEnvironmentVariable_native (IntPtr variable);
+
+               internal static string internalGetEnvironmentVariable (string variable) {
+                       if (variable == null)
+                               return null;
+                       using (var h = Mono.RuntimeMarshal.MarshalString (variable)) {
+                               return internalGetEnvironmentVariable_native (h.Value);
+                       }
+               }
 
                /// <summary>
                /// Return a string containing the value of the environment