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; }