From f1ff6c63c15a302ac53161603d25e68e302f0e9b Mon Sep 17 00:00:00 2001 From: "morse%netscape.com" Date: Sat, 4 Sep 1999 23:26:34 +0000 Subject: [PATCH] fix bug 13068 git-svn-id: svn://10.0.0.236/trunk@46034 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/cookie/nsCookie.cpp | 5 ++--- mozilla/extensions/wallet/src/wallet.cpp | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mozilla/extensions/cookie/nsCookie.cpp b/mozilla/extensions/cookie/nsCookie.cpp index be9c2059b7a..31f0365a5f0 100644 --- a/mozilla/extensions/cookie/nsCookie.cpp +++ b/mozilla/extensions/cookie/nsCookie.cpp @@ -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; } diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index 48e043ef697..0ccf39f8506 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -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; }