Closed Bug 13078 Opened 26 years ago Closed 26 years ago

cookie_Put() -- oddity in char* allocation3

Categories

(Core :: Networking: Cookies, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: bruce, Assigned: morse)

Details

nsresult cookie_Put(nsOutputFileStream strm, const nsString& aLine) { /* allocate a buffer from the heap */ char * cp = new char[aLine.Length() + 1]; if (! cp) { return NS_ERROR_FAILURE; } aLine.ToCString(cp, aLine.Length() + 1); Why not use: char * cp = aLine.ToNewCString(); if (! cp) { return NS_ERROR_FAILURE; } here? if you do that, you need to use nsCRT::free() to deallocate the data as all char* allocation is done with nsAllocator now, not new[]. Even better would be if you could get the buffer without copying it but I don't think that is doable.
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Same problem was in extensions/wallet/src/wallet.cpp. I fixed it in both files and checked it in. Thanks for catching this.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.