Followup to bug 541446 - nsIEnvironment.set will intentionally leak a string when you call it because that is required by the PR_SetEnv API. Make that string something which is not tracked by our leak detector
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 10 Feb 2010 12:57:46 -0500
changeset 38043 6f73d59a7a7b11c420c4b8a9e646431d478f0d33
parent 38042 cb493a28046ec17de4a212c74863f60d0c9097a6
child 38044 afa61580e1a33651d76b376c688d630e33010f22
child 46653 5603d4b9af300439da13f66b6e7ab39b87e76be6
push idunknown
push userunknown
push dateunknown
bugs541446
milestone1.9.3a2pre
Followup to bug 541446 - nsIEnvironment.set will intentionally leak a string when you call it because that is required by the PR_SetEnv API. Make that string something which is not tracked by our leak detector
xpcom/threads/nsEnvironment.cpp
--- a/xpcom/threads/nsEnvironment.cpp
+++ b/xpcom/threads/nsEnvironment.cpp
@@ -132,17 +132,17 @@ nsEnvironment::Get(const nsAString& aNam
     return rv;
 }
 
 /* Environment strings must have static duration; We're gonna leak all of this
  * at shutdown: this is by design, caused how Unix/Linux implement environment
  * vars. 
  */
 
-typedef nsBaseHashtableET<nsCStringHashKey,char*> EnvEntryType;
+typedef nsBaseHashtableET<nsCharPtrHashKey,char*> EnvEntryType;
 typedef nsTHashtable<EnvEntryType> EnvHashType;
 
 static EnvHashType *gEnvHash = nsnull;
 
 static PRBool
 EnsureEnvHash()
 {
     if (gEnvHash)
@@ -173,17 +173,17 @@ nsEnvironment::Set(const nsAString& aNam
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoLock lock(mLock); // autolock unlocks automagically
 
     if (!EnsureEnvHash()){
         return NS_ERROR_UNEXPECTED;
     }
 
-    EnvEntryType* entry = gEnvHash->PutEntry(nativeName);
+    EnvEntryType* entry = gEnvHash->PutEntry(nativeName.get());
     if (!entry) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
     
     char* newData = PR_smprintf("%s=%s",
                                 nativeName.get(),
                                 nativeVal.get());
     if (!newData) {