Bug 97708 - copying text to another application can cause a crash. Need to divide the size of the data in the nsTransferable by 2 to get the number of characters, since they are unicode. r=bbaetz, sr=jst, a=dbaron.

This commit is contained in:
bryner%netscape.com 2002-01-19 04:00:53 +00:00
Родитель 2ee11a6472
Коммит 67d3dc97a7
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -948,11 +948,11 @@ void nsClipboard::SelectionGetCB(GtkWidget *widget,
// Estimate out length and allocate the buffer based on a worst-case estimate, then do
// the conversion.
PRUnichar *castedData = NS_REINTERPRET_CAST(PRUnichar*, clipboardData);
encoder->GetMaxLength(castedData, dataLength, &platformLen);
encoder->GetMaxLength(castedData, dataLength/2, &platformLen);
if ( platformLen ) {
platformText = NS_REINTERPRET_CAST(char*, nsMemory::Alloc(platformLen + sizeof(char)));
if ( platformText ) {
PRInt32 len = (PRInt32)dataLength;
PRInt32 len = (PRInt32)dataLength/2;
rv = encoder->Convert(castedData, &len, platformText, &platformLen);
(platformText)[platformLen] = '\0'; // null terminate. Convert() doesn't do it for us
}