Fixes for bugs in BFlattenable convenience functions (revealed by the new
unit tests). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3404 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c5d8f91d81
commit
df1b8782c7
@ -786,9 +786,13 @@ status_t BMessage::AddFlat(const char* name, BFlattenable* obj, int32 count)
|
||||
ssize_t size = obj->FlattenedSize();
|
||||
char* buffer = new(nothrow) char[size];
|
||||
if (buffer)
|
||||
{
|
||||
err = obj->Flatten((void*)buffer, size);
|
||||
if (!err)
|
||||
{
|
||||
err = AddData(name, obj->TypeCode(), (void*)buffer, size,
|
||||
obj->IsFixedSize(), count);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
else
|
||||
@ -1146,8 +1150,12 @@ status_t BMessage::ReplaceFlat(const char* name, int32 index, BFlattenable* obj)
|
||||
ssize_t size = obj->FlattenedSize();
|
||||
char* buffer = new(nothrow) char[size];
|
||||
if (buffer)
|
||||
{
|
||||
err = obj->Flatten(buffer, size);
|
||||
if (!err)
|
||||
{
|
||||
err = ReplaceData(name, obj->TypeCode(), index, (void*)buffer, size);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user