From c0c883cf8e35433ce0b89bd160741446302efa9e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 29 Aug 2015 11:00:39 +0200 Subject: [PATCH] BMessage: Fix precedence of KMessage vs. size check. A KMessage request always needs to be honoured, regardless of the data size. KMessage does not currently protect against messages that are too large, but this needs to be solved in KMessage when it becomes a problem. --- src/kits/app/Message.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index aa7729cff7..d1824937e7 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -2132,6 +2132,13 @@ BMessage::_SendMessage(port_id port, team_id portOwner, int32 token, return B_NO_MEMORY; } #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST + } else if ((fHeader->flags & MESSAGE_FLAG_REPLY_AS_KMESSAGE) != 0) { + KMessage toMessage; + result = BPrivate::MessageAdapter::ConvertToKMessage(this, toMessage); + if (result != B_OK) + return result; + + return toMessage.SendTo(port, token); } else if (fHeader->data_size > B_PAGE_SIZE * 10) { // ToDo: bind the above size to the max port message size // use message passing by area for such a large message @@ -2166,13 +2173,6 @@ BMessage::_SendMessage(port_id port, team_id portOwner, int32 token, header->message_area = transfered; } #endif - } else if ((fHeader->flags & MESSAGE_FLAG_REPLY_AS_KMESSAGE) != 0) { - KMessage toMessage; - result = BPrivate::MessageAdapter::ConvertToKMessage(this, toMessage); - if (result != B_OK) - return result; - - return toMessage.SendTo(port, token); } else { size = FlattenedSize(); buffer = (char*)malloc(size);