Index: SubWCRev/SubWCRevCOM.cpp
===================================================================
--- SubWCRev/SubWCRevCOM.cpp	(revision 21726)
+++ SubWCRev/SubWCRevCOM.cpp	(working copy)
@@ -43,33 +43,34 @@
 STDAPI DllUnregisterServer();
 static void AutomationMain();
 static void RunOutprocServer();
+static void ImplWinMain();
 
 int APIENTRY _tWinMain(HINSTANCE /*hInstance*/,
                        HINSTANCE /*hPrevInstance*/,
                        LPTSTR    /*lpCmdLine*/,
                        int       /*nCmdShow*/)
 {
+    ImplWinMain();
+    return 0;
+}
+
+static void ImplWinMain()
+{
     int argc = 0;
     LPWSTR * argv = CommandLineToArgvW(GetCommandLine(), &argc);
-    if ((NULL != argv) && (argc >= 2) && (argc <= 5))
+    if (argv == 0)
+        return;
+
+    if ((argc >= 2) && (argc <= 5))
     {
         if (_tcscmp(argv[1], _T("/automation"))==0)
-        {
             AutomationMain();
-            return 0;
-        }
         else if (_tcscmp(argv[1], _T("unregserver"))==0)
-        {
             DllUnregisterServer();
-            return 0;
-        }
         else if (_tcscmp(argv[1], _T("regserver"))==0)
-        {
             DllRegisterServer();
-            return 0;
-        }
     }
-    return 0;
+    LocalFree(argv);
 }
 
 static void AutomationMain()
Index: TortoiseProc/TortoiseProc.cpp
===================================================================
--- TortoiseProc/TortoiseProc.cpp	(revision 21726)
+++ TortoiseProc/TortoiseProc.cpp	(working copy)
@@ -309,8 +309,6 @@
             // and that means the value of /expaths is the current directory, and
             // the selected paths are then added as additional parameters but without a key, only a value
 
-            LPWSTR *szArglist;
-            int nArgs;
             // because of the "strange treatment of quotation marks and backslashes by CommandLineToArgvW"
             // we have to escape the backslashes first. Since we're only dealing with paths here, that's
             // a save bet.
@@ -323,7 +321,8 @@
             // See here for more details: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
             CString cmdLine = GetCommandLineW();
             cmdLine.Replace(L"\\", L"\\\\");
-            szArglist = CommandLineToArgvW(cmdLine, &nArgs);
+            int nArgs = 0;
+            LPWSTR *szArglist = CommandLineToArgvW(cmdLine, &nArgs);
             if (szArglist)
             {
                 // argument 0 is the process path, so start with 1
@@ -339,6 +338,7 @@
                 }
                 sPathArgument.Replace(L"\\\\", L"\\");
             }
+            LocalFree(szArglist);
         }
         if (sPathArgument.IsEmpty() && parser.HasKey(L"path"))
         {
