From a236c8a98bdb8f7d057c4654cb2bd7a3965b14e9 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Tue, 20 Jul 1999 21:02:02 +0000 Subject: [PATCH] Now deletes memory returned from the transferable --- widget/src/windows/nsClipboard.cpp | 4 ++++ widget/src/windows/nsDataObj.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/widget/src/windows/nsClipboard.cpp b/widget/src/windows/nsClipboard.cpp index b222cff21f3e..5232dbfa3f2a 100644 --- a/widget/src/windows/nsClipboard.cpp +++ b/widget/src/windows/nsClipboard.cpp @@ -631,12 +631,16 @@ NS_IMETHODIMP nsClipboard::ForceDataToClipboard() PRUint32 dataLen; // Get the data as a bunch-o-bytes from the clipboard + // this call hands back new memory with the contents copied into it mTransferable->GetTransferData(df, &data, &dataLen); // now place it on the Clipboard if (nsnull != data) { PlaceDataOnClipboard(format, (char *)data, dataLen); } + + // Now, delete the memory that was created by the transferable + delete [] data; } } delete dfList; diff --git a/widget/src/windows/nsDataObj.cpp b/widget/src/windows/nsDataObj.cpp index dd073cee6c9d..2eafc25136e4 100644 --- a/widget/src/windows/nsDataObj.cpp +++ b/widget/src/windows/nsDataObj.cpp @@ -329,7 +329,7 @@ HRESULT nsDataObj::GetText(nsString * aDF, FORMATETC& aFE, STGMEDIUM& aSTG) char * data; PRUint32 len; - // NOTE: Transferable keeps ownership of the memory + // NOTE: Transferable creates new memory, that needs to be deleted mTransferable->GetTransferData(aDF, (void **)&data, &len); if (0 == len) { return ResultFromScode(E_FAIL); @@ -387,6 +387,9 @@ HRESULT nsDataObj::GetText(nsString * aDF, FORMATETC& aFE, STGMEDIUM& aSTG) aSTG.hGlobal = hGlobalMemory; + // Now, delete the memory that was created by the transferable + delete [] data; + return ResultFromScode(S_OK); }