correct command line handling in lean explorer
Modified: branches/lean-explorer/reactos/subsys/system/explorer/explorer.cpp

Modified: branches/lean-explorer/reactos/subsys/system/explorer/explorer.cpp
--- branches/lean-explorer/reactos/subsys/system/explorer/explorer.cpp	2005-12-28 02:20:27 UTC (rev 20390)
+++ branches/lean-explorer/reactos/subsys/system/explorer/explorer.cpp	2005-12-28 12:27:25 UTC (rev 20391)
@@ -452,10 +452,14 @@
 			cmd.ParseCmdLine(lpCmdLine);
 
 		 // Open the first child window after initializing the application
-		if (cmd.IsValidPath())
-			PostMessage(hMainFrame, PM_OPEN_WINDOW, cmd._flags, (LPARAM)lpCmdLine);
-		else
-			PostMessage(hMainFrame, PM_OPEN_WINDOW, 0/*OWM_EXPLORE|OWM_DETAILS*/, 0);
+		if (cmd.IsValidPath()) {
+			 // We use the static s_path variable to store the path string in order 
+			 // to avoid accessing prematurely freed memory in the PostMessage handlers.
+			static String s_path = cmd._path;
+
+			PostMessage(hMainFrame, PM_OPEN_WINDOW, cmd._flags, (LPARAM)(LPCTSTR)s_path);
+		} else
+			PostMessage(hMainFrame, PM_OPEN_WINDOW, cmd._flags, 0);
 	}
 }