* 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...



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24196 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich 2008-03-02 00:06:45 +00:00
parent 18c2aaaea2
commit 0f9d90aa24

View File

@ -2300,13 +2300,25 @@ BMessage::AddMessage(const char *name, const BMessage *message)
copying an extra buffer. Functions can be added that return a direct
pointer into the message. */
char buf[4096] = { 0 };
ssize_t size = message->FlattenedSize();
char buffer[size];
bool freeBuffer = false;
char* buffer = NULL;
if (size > (ssize_t)sizeof(buffer)) {
freeBuffer = true;
buffer = static_cast<char*>(malloc(size));
} else {
buffer = buf;
}
status_t error = message->Flatten(buffer, size);
if (error >= B_OK)
error = AddData(name, B_MESSAGE_TYPE, &buffer, size, false);
error = AddData(name, B_MESSAGE_TYPE, buffer, size, false);
if (freeBuffer)
free(buffer);
return error;
}