Changeset 24196

Show
Ignore:
Timestamp:
03/01/08 19:06:45 (9 months ago)
Author:
julun
Message:

* This fixes ticket #1865
* Allocate the buffer to flatten the message on the heap, if it's size is bigger then a given

buffer on the stack. It seem's to exceed the stack size (this might count for AddFlat() too).

Note: With this change one is able to copy the text into the clipboard (1mb), but it

is still impossible to paste it somewhere, as in BClipboard::_DownloadFromSystem()
SendMessage() fails transferring the data back in the reply msg because of the port size limit...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/kits/app/Message.cpp

    r23810 r24196  
    23012301        pointer into the message. */ 
    23022302 
     2303        char buf[4096] = { 0 }; 
    23032304        ssize_t size = message->FlattenedSize(); 
    2304         char buffer[size]; 
     2305 
     2306        bool freeBuffer = false; 
     2307        char* buffer = NULL; 
     2308        if (size > (ssize_t)sizeof(buffer)) { 
     2309                freeBuffer = true; 
     2310                buffer = static_cast<char*>(malloc(size)); 
     2311        } else { 
     2312                buffer = buf; 
     2313        } 
    23052314 
    23062315        status_t error = message->Flatten(buffer, size); 
    23072316 
    23082317        if (error >= B_OK) 
    2309                 error = AddData(name, B_MESSAGE_TYPE, &buffer, size, false); 
     2318                error = AddData(name, B_MESSAGE_TYPE, buffer, size, false); 
     2319 
     2320        if (freeBuffer) 
     2321                free(buffer); 
    23102322 
    23112323        return error;