зеркало из https://github.com/mozilla/pjs.git
correctly check result codes of OS calls and null terminate the exported mappings for placing on the clipboard. Fixes bug #11569 (appr chofmann).
This commit is contained in:
Родитель
a3a680a578
Коммит
1e3863c605
|
@ -148,7 +148,8 @@ nsClipboard :: SetNativeClipboardData()
|
|||
} // foreach flavor in transferable
|
||||
delete flavorList;
|
||||
|
||||
// write out the mapping data in a special flavor on the clipboard
|
||||
// write out the mapping data in a special flavor on the clipboard. |mappingLen|
|
||||
// includes the NULL terminator.
|
||||
short mappingLen = 0;
|
||||
const char* mapping = theMapper.ExportMapping(&mappingLen);
|
||||
long numBytes = ::PutScrap ( mappingLen, nsMimeMapperMac::MappingFlavor(), mapping );
|
||||
|
@ -188,7 +189,7 @@ nsClipboard :: GetNativeClipboardData(nsITransferable * aTransferable)
|
|||
GetDataOffClipboard ( nsMimeMapperMac::MappingFlavor(), &mimeMapperData, nsnull );
|
||||
nsMimeMapperMac theMapper ( mimeMapperData );
|
||||
delete [] mimeMapperData;
|
||||
|
||||
|
||||
//
|
||||
// Now walk down the list of flavors. When we find one that is actually on the
|
||||
// clipboard, copy out the data into the transferable in that format. SetTransferData()
|
||||
|
@ -232,8 +233,9 @@ nsClipboard :: GetDataOffClipboard ( ResType inMacFlavor, char** outData, long*
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
// check if it is on the clipboard
|
||||
long offsetUnused;
|
||||
if ( ::GetScrap(NULL, inMacFlavor, &offsetUnused) > 0 ) {
|
||||
long offsetUnused = 0;
|
||||
OSErr clipResult = ::GetScrap(NULL, inMacFlavor, &offsetUnused);
|
||||
if ( clipResult > 0 ) {
|
||||
// we have it, get it off the clipboard. Put it into memory that we allocate
|
||||
// with new[] so that the tranferable can own it (and then later use delete[]
|
||||
// on it).
|
||||
|
|
|
@ -152,6 +152,8 @@ nsMimeMapperMac :: ParseMappings ( const char* inMappings )
|
|||
mMappings.push_back( MimePair(flavor, mimeType) );
|
||||
|
||||
currPosition += 10 + 2 + strlen(mimeType); // see ExportMapping() for explanation of this calculation
|
||||
|
||||
++mCounter;
|
||||
} // while we're not at the end yet
|
||||
|
||||
} // ParseMappings
|
||||
|
@ -163,7 +165,8 @@ nsMimeMapperMac :: ParseMappings ( const char* inMappings )
|
|||
// The mappings are of the form
|
||||
// <# of pairs> 1..N of (<4 char code> <space> <mime type> <space>)
|
||||
//
|
||||
// Caller is responsible for disposing of the memory allocated here
|
||||
// Caller is responsible for disposing of the memory allocated here. |outLength| counts
|
||||
// the null at the end of the string.
|
||||
//
|
||||
char*
|
||||
nsMimeMapperMac :: ExportMapping ( short * outLength ) const
|
||||
|
@ -219,7 +222,7 @@ nsMimeMapperMac :: ExportMapping ( short * outLength ) const
|
|||
} // if we got the memory
|
||||
} // if there is anything in our list
|
||||
|
||||
*outLength = len;
|
||||
*outLength = len + 1; // don't forget the NULL
|
||||
return exportBuffer;
|
||||
|
||||
} // ExportMapping
|
||||
|
|
|
@ -64,7 +64,8 @@ public:
|
|||
void MapMacOSTypeToMimeType ( ResType inMacType, nsString & outMimeStr ) ;
|
||||
|
||||
// Takes the internal mappings and converts them to a string for
|
||||
// placing on the clipboard or in a drag item.
|
||||
// placing on the clipboard or in a drag item. |outLength| includes
|
||||
// the NULL at the end of the string.
|
||||
char* ExportMapping ( short * outLength ) const;
|
||||
|
||||
static ResType MappingFlavor ( ) { return kMappingFlavor; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче