From cdbdb080a4d99acf8d00106b6687e452b2ce50bf Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Tue, 29 Dec 1998 01:03:26 +0000 Subject: [PATCH] Fixed memory leak in ToString() git-svn-id: svn://10.0.0.236/trunk@16917 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/module/nsHttpUrl.cpp | 28 ++++++++++++------------- mozilla/network/module/nsNetService.cpp | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mozilla/network/module/nsHttpUrl.cpp b/mozilla/network/module/nsHttpUrl.cpp index 787ccee3940..3d5b2ce5653 100644 --- a/mozilla/network/module/nsHttpUrl.cpp +++ b/mozilla/network/module/nsHttpUrl.cpp @@ -883,37 +883,37 @@ nsresult nsHttpUrlImpl::SetPostData(nsIInputStream* input) nsresult nsHttpUrlImpl::ToString(PRUnichar* *unichars) const { - nsString& aString = *new nsString(); + nsAutoString string; NS_LOCK_INSTANCE(); // XXX Special-case javascript: URLs for the moment. // This code will go away when we actually start doing // protocol-specific parsing. if (PL_strcmp(mProtocol, "javascript") == 0) { - aString.SetString(mSpec); + string.SetString(mSpec); } else { - aString.SetLength(0); - aString.Append(mProtocol); - aString.Append("://"); + string.SetLength(0); + string.Append(mProtocol); + string.Append("://"); if (nsnull != mHost) { - aString.Append(mHost); + string.Append(mHost); if (0 < mPort) { - aString.Append(':'); - aString.Append(mPort, 10); + string.Append(':'); + string.Append(mPort, 10); } } - aString.Append(mFile); + string.Append(mFile); if (nsnull != mRef) { - aString.Append('#'); - aString.Append(mRef); + string.Append('#'); + string.Append(mRef); } if (nsnull != mSearch) { - aString.Append('?'); - aString.Append(mSearch); + string.Append('?'); + string.Append(mSearch); } } NS_UNLOCK_INSTANCE(); - *unichars = aString.ToNewUnicode(); + *unichars = string.ToNewUnicode(); return NS_OK; } diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index 9b76be01c82..42613d244d6 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -953,7 +953,7 @@ NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL, err = url->ToString(&str); if (err) goto done; string = new nsString(str); - delete str; + delete []str; if (string == NULL) err = NS_ERROR_OUT_OF_MEMORY; else