Bug 714286 followup - Fix the temp path detection code for Windows; r=mccr8
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 03 Jan 2012 22:53:30 -0500
changeset 84954 06de54d7d7b47bb5bc22ce97d1fbe2da2429f891
parent 84953 52d9d7bbfad1d3d29a972ec92ebc3cf035e4c3b9
child 84955 0eec6ba6a87aa3149854bb7680eff9ac0cb924f4
child 84967 64d814cd18b35b73ddbb568b026d1df11a85b2dd
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs714286
milestone12.0a1
Bug 714286 followup - Fix the temp path detection code for Windows; r=mccr8
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1396,21 +1396,27 @@ public:
     {
       *aAllTraces = mWantAllTraces;
       return NS_OK;
     }
 
     NS_IMETHOD Begin()
     {
         char name[MAXPATHLEN] = {'\0'};
+#ifdef XP_WIN
+        // On Windows, tmpnam returns useless stuff, such as "\\s164.".
+        // Therefore we need to call the APIs directly.
+        GetTempPathA(mozilla::ArrayLength(name), name);
+#else
         tmpnam(name);
         char *lastSlash = strrchr(name, XPCOM_FILE_PATH_SEPARATOR[0]);
         if (lastSlash) {
             *lastSlash = '\0';
         }
+#endif
         sprintf(name, "%s%scc-edges-%d.%d.log", name,
                 XPCOM_FILE_PATH_SEPARATOR,
                 ++gLogCounter, base::GetCurrentProcId());
         mStream = fopen(name, "w");
 
         nsCOMPtr<nsIConsoleService> cs =
             do_GetService(NS_CONSOLESERVICE_CONTRACTID);
         if (cs) {