Cleanup from previous commit
authorBrian R. Bondy <netzen@gmail.com>
Mon, 27 Apr 2015 10:32:18 -0400
changeset 491417 52a2e2de9280c2604fd4381413384c9f616a1d15
parent 491416 9f405a2009833102c9aab45477b6bb053ad45bb4
child 491418 68cc6f7bcd90158d703381bdce3fed3f211bcd06
push id47343
push userbmo:dothayer@mozilla.com
push dateWed, 01 Mar 2017 22:58:58 +0000
milestone40.0a1
Cleanup from previous commit
toolkit/xre/nsUpdateDriver.cpp
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -397,38 +397,40 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir
 #endif
   rv = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterBin));
   return NS_SUCCEEDED(rv); 
 }
 
 /**
  * Appends the specified path to the library path.
  * This is used so that updater can find libmozsqlite3.so and other shared libs.
+ *
+ * @param newPathToCheck A new library path to prepend to LD_LIBRARY_PATH
  */
 #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && !defined(XP_MACOSX)
 #include "prprf.h"
 #define PATH_SEPARATOR ":"
 #define LD_LIBRARY_PATH_ENVVAR_NAME "LD_LIBRARY_PATH"
 static void
 AppendToLibPath(const char *newPathToCheck)
 {
   char *s = nullptr;
   char *pathValue = getenv(LD_LIBRARY_PATH_ENVVAR_NAME);
   if (nullptr == pathValue || '\0' == *pathValue) {
     s = PR_smprintf("%s=%s", LD_LIBRARY_PATH_ENVVAR_NAME, newPathToCheck);
   } else {
     s = PR_smprintf("%s=%s" PATH_SEPARATOR "%s",
                     LD_LIBRARY_PATH_ENVVAR_NAME, newPathToCheck, pathValue);
   }
-  //putenv(s);
 
-  // We intentionally leak the value that is passed into PR_SetEnv() because
-  // the environment will hold a pointer to it.
+  // The memory used by PR_SetEnv is not copied to the environment on all
+  // platform, it can be used by reference directly. So we purposely do not
+  // call PR_smprintf_free on s.  Subsequent calls to PR_SetEnv will free
+  // the old memory first.
   PR_SetEnv(s);
-  //PR_smprintf_free(s);
 }
 #endif
 
 /**
  * Switch an existing application directory to an updated version that has been
  * staged.
  *
  * @param greDir the GRE dir