Fixed potential memory leak. If user tried to add data of type X when we already had data of type Y with the same name, a new BMessageField of type Y would be created and added to the field map, leaving the old type X field orphaned.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8613 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2004-08-20 18:14:05 +00:00
parent c78e2a47c0
commit a7529effe6
+12 -2
View File
@@ -125,8 +125,18 @@ status_t BMessageBody::AddData(const char *name, const T1 &data, type_code type)
status_t err = B_OK;
BMessageField* BMF = FindData(name, type, err);
// Reset err; we just want the variable
err = B_OK;
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)
{