From f75c8c97ff5c6a7dacc598ff4740cbbe89c026d4 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Wed, 17 May 2006 02:38:17 +0000 Subject: [PATCH] Bug 220093 inCSSValueSearch incorrectly uses strings r=caillon sr=bz --- layout/inspector/src/inCSSValueSearch.cpp | 18 +++++++----------- layout/inspector/src/inCSSValueSearch.h | 6 +++--- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/layout/inspector/src/inCSSValueSearch.cpp b/layout/inspector/src/inCSSValueSearch.cpp index 741475709548..2a7bfe8988c7 100644 --- a/layout/inspector/src/inCSSValueSearch.cpp +++ b/layout/inspector/src/inCSSValueSearch.cpp @@ -49,9 +49,6 @@ static NS_DEFINE_CID(kInspectorCSSUtilsCID, NS_INSPECTORCSSUTILS_CID); inCSSValueSearch::inCSSValueSearch() : mResults(nsnull), mProperties(nsnull), - mLastResult(nsnull), - mBaseURL(nsnull), - mTextCriteria(nsnull), mResultCount(0), mPropertyCount(0), mIsActive(PR_FALSE), @@ -154,7 +151,7 @@ inCSSValueSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval) nsAutoString* result = (nsAutoString*)mResults->ElementAt(aIndex); _retval = *result; } else if (aIndex == mResultCount-1) { - _retval = *mLastResult; + _retval = mLastResult; } else { return NS_ERROR_FAILURE; } @@ -194,16 +191,15 @@ inCSSValueSearch::SetDocument(nsIDOMDocument* aDocument) NS_IMETHODIMP inCSSValueSearch::GetBaseURL(PRUnichar** aBaseURL) { - *aBaseURL = ToNewUnicode(*mBaseURL); + if (!(*aBaseURL = ToNewUnicode(mBaseURL))) + return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } NS_IMETHODIMP inCSSValueSearch::SetBaseURL(const PRUnichar* aBaseURL) { - nsAutoString url; - mBaseURL = &url; - url.Assign(aBaseURL); + mBaseURL.Assign(aBaseURL); return NS_OK; } @@ -248,15 +244,15 @@ inCSSValueSearch::AddPropertyCriteria(const PRUnichar *aPropName) NS_IMETHODIMP inCSSValueSearch::GetTextCriteria(PRUnichar** aTextCriteria) { - *aTextCriteria = ToNewUnicode(*mTextCriteria); + if (!(*aTextCriteria = ToNewUnicode(mTextCriteria))) + return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } NS_IMETHODIMP inCSSValueSearch::SetTextCriteria(const PRUnichar* aTextCriteria) { - if (!mTextCriteria) mTextCriteria = new nsAutoString(); - mTextCriteria->Assign(aTextCriteria); + mTextCriteria.Assign(aTextCriteria); return NS_OK; } diff --git a/layout/inspector/src/inCSSValueSearch.h b/layout/inspector/src/inCSSValueSearch.h index 65195ce9a0c2..6034d128f42f 100644 --- a/layout/inspector/src/inCSSValueSearch.h +++ b/layout/inspector/src/inCSSValueSearch.h @@ -68,9 +68,9 @@ protected: nsCOMPtr mDocument; nsVoidArray* mResults; nsCSSProperty* mProperties; - nsAutoString* mLastResult; - nsAutoString* mBaseURL; - nsAutoString* mTextCriteria; + nsString mLastResult; + nsString mBaseURL; + nsString mTextCriteria; PRInt32 mResultCount; PRUint32 mPropertyCount; PRBool mIsActive;