Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mono / metadata / console-unix.c
index 2ad4210f7563f413d0175f37021fcfe1b6fd8b40..98b3ba551cb005a3af4cbadc884cb576a81e4984 100644 (file)
@@ -457,12 +457,16 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardow
        if (dims == -1){
                int cols = 0, rows = 0;
                                      
-               const char *str = g_getenv ("COLUMNS");
-               if (str != NULL)
+               char *str = g_getenv ("COLUMNS");
+               if (str != NULL) {
                        cols = atoi (str);
+                       g_free (str);
+               }
                str = g_getenv ("LINES");
-               if (str != NULL)
+               if (str != NULL) {
                        rows = atoi (str);
+                       g_free (str);
+               }
 
                if (cols != 0 && rows != 0)
                        cols_and_lines = (cols << 16) | rows;