diff --git a/headers/private/app/MessageBody.h b/headers/private/app/MessageBody.h index 153458a348..b68143f40f 100644 --- a/headers/private/app/MessageBody.h +++ b/headers/private/app/MessageBody.h @@ -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) { @@ -142,7 +152,7 @@ status_t BMessageBody::AddData(const char *name, const T1 &data, type_code type) } if (!err) - { + { BMessageFieldImpl* RItem = dynamic_cast*>(BMF); if (!RItem)