--- src/subshell.c
+++ src/subshell.c
@@ -267,11 +267,14 @@
         putenv (g_strdup (sid_str));
     }
 
+    char *putenv_str = NULL;
     switch (subshell_type)
     {
     case BASH:
+        /* Do we have a custom init file ~/.local/share/mc/bashrc? */
         init_file = mc_config_get_full_path ("bashrc");
 
+        /* Otherwise use ~/.bashrc */
         if (access (init_file, R_OK) == -1)
         {
             g_free (init_file);
@@ -286,9 +289,9 @@
             char *input_file = mc_config_get_full_path ("inputrc");
             if (access (input_file, R_OK) == 0)
             {
-                char *putenv_str = g_strconcat ("INPUTRC=", input_file, NULL);
+                putenv_str = g_strconcat ("INPUTRC=", input_file, NULL);
                 putenv (putenv_str);
-                g_free (putenv_str);
+                /* Do not use "g_free (putenv_str)" here, otherwise INPUTRC will be undefined! */
             }
             g_free (input_file);
         }
@@ -351,6 +354,7 @@
 
     /* If we get this far, everything failed miserably */
     g_free (init_file);
+    g_free (putenv_str);
     my_exit (FORK_FAILURE);
 }
 
