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
This commit is contained in:
Michael Lotz 2008-09-13 17:31:13 +00:00
parent bbe2597fb6
commit c66c6997db

View File

@ -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: