fix bug 13068

git-svn-id: svn://10.0.0.236/trunk@46034 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
morse%netscape.com
1999-09-04 23:26:34 +00:00
parent 99c0c376f3
commit f1ff6c63c1
2 changed files with 5 additions and 8 deletions

View File

@@ -322,18 +322,17 @@ nsresult
cookie_Put(nsOutputFileStream strm, const nsString& aLine)
{
/* allocate a buffer from the heap */
char * cp = new char[aLine.Length() + 1];
char * cp = aLine.ToNewCString();
if (! cp) {
return NS_ERROR_FAILURE;
}
aLine.ToCString(cp, aLine.Length() + 1);
/* output each character */
char* p = cp;
while (*p) {
strm.put(*(p++));
}
delete[] cp;
nsCRT::free(cp);
return NS_OK;
}

View File

@@ -1444,13 +1444,11 @@ PRInt32
wallet_PutLine(nsOutputFileStream strm, const nsString& aLine, PRBool obscure)
{
/* allocate a buffer from the heap */
char * cp = new char[aLine.Length() + 1];
char * cp = aLine.ToNewCString();
if (! cp) {
return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_FAILURE;
}
aLine.ToCString(cp, aLine.Length() + 1);
/* output each character */
char* p = cp;
while (*p) {
@@ -1458,7 +1456,7 @@ wallet_PutLine(nsOutputFileStream strm, const nsString& aLine, PRBool obscure)
}
strm.put('\n'^(obscure ? Wallet_GetKey() : (char)0));
delete[] cp;
nsCRT::free(cp);
return 0;
}