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