From c66c6997dba7ba4371e73f285da20d8bcb990c78 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 13 Sep 2008 17:31:13 +0000 Subject: [PATCH] CID 225: If the field size was <= 0 the field buffer wasn't allocated but still used in the switch statement. Change that to continue early when a filed size of <= 0 is encountered. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27488 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/MessageAdapter.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/kits/app/MessageAdapter.cpp b/src/kits/app/MessageAdapter.cpp index 21136c0028..bce5957933 100644 --- a/src/kits/app/MessageAdapter.cpp +++ b/src/kits/app/MessageAdapter.cpp @@ -679,15 +679,18 @@ MessageAdapter::_UnflattenDanoMessage(uint32 format, BMessage *into, ssize_t fieldSize = sectionHeader.size - sizeof(dano_section_header); uint8 *fieldBuffer = NULL; - if (fieldSize > 0) { + if (fieldSize <= 0) { // there may be no data. we shouldn't fail because of that - fieldBuffer = (uint8 *)malloc(fieldSize); - if (fieldBuffer == NULL) - throw (status_t)B_NO_MEMORY; - - reader(fieldBuffer, fieldSize); + offset += sectionHeader.size; + continue; } + fieldBuffer = (uint8 *)malloc(fieldSize); + if (fieldBuffer == NULL) + throw (status_t)B_NO_MEMORY; + + reader(fieldBuffer, fieldSize); + switch (sectionHeader.code) { case SECTION_OFFSET_TABLE: case SECTION_TARGET_INFORMATION: