[Fix] Cleanup emu environment items on exit.
authorace20022 <ace20022@ymail.com>
Thu, 19 Jun 2014 10:16:58 +0000 (12:16 +0200)
committerace20022 <ace20022@ymail.com>
Sat, 21 Jun 2014 08:45:14 +0000 (10:45 +0200)
xbmc/Application.cpp
xbmc/cores/DllLoader/exports/emu_msvcrt.cpp

index 155b17c..4d03570 100644 (file)
@@ -596,6 +596,7 @@ bool CApplication::OnEvent(XBMC_Event& newEvent)
 
 extern "C" void __stdcall init_emu_environ();
 extern "C" void __stdcall update_emu_environ();
+extern "C" void __stdcall cleanup_emu_environ();
 
 //
 // Utility function used to copy files from the application bundle
@@ -3613,6 +3614,7 @@ void CApplication::Stop(int exitCode)
   // we may not get to finish the run cycle but exit immediately after a call to g_application.Stop()
   // so we may never get to Destroy() in CXBApplicationEx::Run(), we call it here.
   Destroy();
+  cleanup_emu_environ();
 
   //
   Sleep(200);
index ae7ccb5..0b07868 100644 (file)
@@ -225,6 +225,15 @@ extern "C" void __stdcall update_emu_environ()
   }
 }
 
+extern "C" void __stdcall cleanup_emu_environ()
+{
+  for (int i = 0; i < EMU_MAX_ENVIRONMENT_ITEMS; i++)
+  {
+    free(dll__environ[i]);
+    dll__environ[i] = NULL;
+  }
+}
+
 static int convert_fmode(const char* mode)
 {
   int iMode = O_BINARY;