Fixed a couple of memory leaks and an incorrect index bounds check.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8635 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2004-08-24 23:54:02 +00:00
parent 968aa8c895
commit 72a804515c
3 changed files with 39 additions and 17 deletions
+13 -10
View File
@@ -125,17 +125,20 @@ status_t BMessageBody::AddData(const char *name, const T1 &data, type_code type)
status_t err = B_OK;
BMessageField* BMF = FindData(name, type, err);
if (err == B_NAME_NOT_FOUND)
if (err)
{
// Reset err; we'll create the field
err = B_OK;
}
else
{
// Looking for B_BAD_TYPE here in particular, which would indicate
// that we tried to add data of type X when we already had data of
// type Y with the same name
return err;
if (err == B_NAME_NOT_FOUND)
{
// Reset err; we'll create the field
err = B_OK;
}
else
{
// Looking for B_BAD_TYPE here in particular, which would indicate
// that we tried to add data of type X when we already had data of
// type Y with the same name
return err;
}
}
if (!BMF)
+8 -6
View File
@@ -375,14 +375,16 @@ const void*
BMessageFieldImpl<T1, StoragePolicy, SizePolicy, PrintPolicy, FlattenPolicy, GetDataPolicy>::
DataAt(int32 index, ssize_t* size) const
{
if (index > CountItems())
return NULL;
if (index < CountItems())
{
*size = SizePolicy::Size(fData[index]);
const T1& ref = fData[index];
const T1* data = &ref;
*size = SizePolicy::Size(fData[index]);
const T1& ref = fData[index];
const T1* data = &ref;
return GetDataPolicy::GetData(data);//(const void*)data;
}
return GetDataPolicy::GetData(data);//(const void*)data;
return NULL;
}
//------------------------------------------------------------------------------
template