From 1bfcb75b292142bbbd2ac65a5e90d194bfdbe0f8 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 6 Jan 2015 16:18:34 +0100 Subject: [PATCH] BMessage: fix passing messages by area I missed the fact that the BDataIO based Unflatten didn't handle this. Restore the code from the recently removed buffer-based unflatten, so it's possible to pass a message by area again. --- src/kits/app/Message.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index c6992cdcca..4b6708d220 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -1311,19 +1311,28 @@ BMessage::Unflatten(BDataIO* stream) what = fHeader->what; - fHeader->message_area = -1; - - if (fHeader->field_count > 0) { - ssize_t fieldsSize = fHeader->field_count * sizeof(field_header); - fFields = (field_header*)malloc(fieldsSize); - if (fFields == NULL) { + if ((fHeader->flags & MESSAGE_FLAG_PASS_BY_AREA) != 0 + && fHeader->message_area >= 0) { + status_t result = _Reference(); + if (result != B_OK) { _InitHeader(); - return B_NO_MEMORY; + return result; } + } else { + fHeader->message_area = -1; - result = stream->Read(fFields, fieldsSize); - if (result != fieldsSize) - return result < 0 ? result : B_BAD_VALUE; + if (fHeader->field_count > 0) { + ssize_t fieldsSize = fHeader->field_count * sizeof(field_header); + fFields = (field_header*)malloc(fieldsSize); + if (fFields == NULL) { + _InitHeader(); + return B_NO_MEMORY; + } + + result = stream->Read(fFields, fieldsSize); + if (result != fieldsSize) + return result < 0 ? result : B_BAD_VALUE; + } } if (fHeader->data_size > 0) {