From 154c45dfa180019a6e384dc7da88e1829329e02c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 10 Oct 2007 02:10:01 +0000 Subject: [PATCH] Don't leak strings from . Bug 398665, r=kaie, sr=jst, a=dbaron git-svn-id: svn://10.0.0.236/trunk@237501 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/content/public/nsIFormProcessor.h | 10 ++++++---- mozilla/parser/htmlparser/src/CNavDTD.cpp | 4 ++-- mozilla/security/manager/ssl/src/nsKeygenHandler.cpp | 8 +++++--- mozilla/security/manager/ssl/src/nsKeygenHandler.h | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mozilla/content/html/content/public/nsIFormProcessor.h b/mozilla/content/html/content/public/nsIFormProcessor.h index 826d5428c13..1c9ec1893c3 100644 --- a/mozilla/content/html/content/public/nsIFormProcessor.h +++ b/mozilla/content/html/content/public/nsIFormProcessor.h @@ -51,7 +51,7 @@ #include "nsIDOMHTMLInputElement.h" class nsString; -class nsVoidArray; +class nsStringArray; // {0ae53c0f-8ea2-4916-bedc-717443c3e185} #define NS_FORMPROCESSOR_CID \ @@ -59,9 +59,11 @@ class nsVoidArray; #define NS_FORMPROCESSOR_CONTRACTID "@mozilla.org/layout/form-processor;1" -// 4ff86376-6982-4f64-a683-a6ae4984afd7 +// 6d4ea1aa-a6b2-43bd-a19d-3f0f26750df3 #define NS_IFORMPROCESSOR_IID \ -{ 0x4ff86376, 0x6982, 0x4f64, { 0xa6, 0x83, 0xa6, 0xae, 0x49, 0x84, 0xaf, 0xd7 } } +{ 0x6d4ea1aa, 0xa6b2, 0x43bd, \ + { 0xa1, 0x9d, 0x3f, 0x0f, 0x26, 0x75, 0x0d, 0xf3 } } + @@ -101,7 +103,7 @@ public: */ NS_IMETHOD ProvideContent(const nsAString& aFormType, - nsVoidArray& aContent, + nsStringArray& aContent, nsAString& aAttribute) = 0; }; diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 857c7de9335..a2363dc4858 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -1140,7 +1140,7 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNode) if (NS_SUCCEEDED(result)) { PRInt32 theAttrCount = aNode->GetAttributeCount(); - nsVoidArray theContent; + nsStringArray theContent; nsAutoString theAttribute; nsAutoString theFormType; CToken* theToken = nsnull; @@ -1163,7 +1163,7 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNode) mTokenizer->PushTokenFront(theToken); for (theIndex = theContent.Count()-1; theIndex > -1; --theIndex) { - theTextValue = (nsString*)theContent[theIndex]; + theTextValue = theContent[theIndex]; theToken = mTokenAllocator->CreateTokenOfType(eToken_text, eHTMLTag_text, *theTextValue); diff --git a/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp b/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp index c8a682540e5..c15f7c701d6 100644 --- a/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp +++ b/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp @@ -349,6 +349,9 @@ nsKeygenFormProcessor::Init() if (NS_FAILED(rv)) return rv; + // XXXbz this leaks the strings through shutdown. There's got to be + // a better way to do this! Of course that would involve having SOME + // shutdown code somewhere here. nssComponent->GetPIPNSSBundleString("HighGrade", str); SECKeySizeChoiceList[0].name = ToNewUnicode(str); @@ -857,14 +860,13 @@ nsKeygenFormProcessor::ProcessValue(nsIDOMHTMLElement *aElement, } NS_METHOD nsKeygenFormProcessor::ProvideContent(const nsAString& aFormType, - nsVoidArray& aContent, + nsStringArray& aContent, nsAString& aAttribute) { if (Compare(aFormType, NS_LITERAL_STRING("SELECT"), nsCaseInsensitiveStringComparator()) == 0) { for (SECKeySizeChoiceInfo* choice = SECKeySizeChoiceList; choice && choice->name; ++choice) { - nsString *str = new nsString(choice->name); - aContent.AppendElement(str); + aContent.AppendString(nsDependentString(choice->name)); } aAttribute.AssignLiteral("-mozilla-keygen"); } diff --git a/mozilla/security/manager/ssl/src/nsKeygenHandler.h b/mozilla/security/manager/ssl/src/nsKeygenHandler.h index 2be97d77129..b172bd83da9 100644 --- a/mozilla/security/manager/ssl/src/nsKeygenHandler.h +++ b/mozilla/security/manager/ssl/src/nsKeygenHandler.h @@ -67,7 +67,7 @@ public: nsAString& aValue); NS_IMETHOD ProvideContent(const nsAString& aFormType, - nsVoidArray& aContent, + nsStringArray& aContent, nsAString& aAttribute); NS_DECL_ISUPPORTS