From 6109079414145cf49dd9b3ba6ce0f92d1d5e9d54 Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Tue, 13 Apr 2004 05:28:12 +0000 Subject: [PATCH] Bug 238455 warning C4244: 'argument' : conversion from 'PRInt64' to 'size_t', possible loss of data r=roc sr=dveditz --- widget/src/xpwidgets/nsTransferable.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/widget/src/xpwidgets/nsTransferable.cpp b/widget/src/xpwidgets/nsTransferable.cpp index 6212b07915af..210e20f3d0fe 100644 --- a/widget/src/xpwidgets/nsTransferable.cpp +++ b/widget/src/xpwidgets/nsTransferable.cpp @@ -247,10 +247,15 @@ DataStruct::ReadCache(nsISupports** aData, PRUint32* aDataLen) if ( cacheFile && NS_SUCCEEDED(cacheFile->Exists(&exists)) && exists ) { // get the size of the file PRInt64 fileSize; + PRInt64 max32(LL_INIT(0, 0xFFFFFFFF)); cacheFile->GetFileSize(&fileSize); + if (LL_CMP(fileSize, >, max32)) + return NS_ERROR_OUT_OF_MEMORY; + PRUint32 size; + LL_L2UI(size, fileSize); // create new memory for the large clipboard data - char * data = (char *)nsMemory::Alloc(fileSize); + char * data = (char *)nsMemory::Alloc(size); if ( !data ) return NS_ERROR_OUT_OF_MEMORY; @@ -264,8 +269,7 @@ DataStruct::ReadCache(nsISupports** aData, PRUint32* aDataLen) nsresult rv = inStr->Read(data, fileSize, aDataLen); // make sure we got all the data ok - if ( NS_SUCCEEDED(rv) && *aDataLen == (PRUint32)fileSize) { - *aDataLen = fileSize; + if (NS_SUCCEEDED(rv) && *aDataLen == size) { nsPrimitiveHelpers::CreatePrimitiveForData ( mFlavor.get(), data, fileSize, aData ); return *aData ? NS_OK : NS_ERROR_FAILURE; }