Fix MIME type creation error

DatabaseLocation::OpenOrCreateType(): BNode::WriteAttr() returns the
number of bytes written, not just an error code., so we erroneously
reported an error on success.

Fixes the first part of #9845.
This commit is contained in:
Ingo Weinhold 2013-07-01 14:17:51 +02:00
parent 4f82f6fa72
commit c09ec54a59

View File

@ -114,8 +114,14 @@ DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,
return error;
// write the type attribute
error = _node.WriteAttr(kTypeAttr, B_STRING_TYPE, 0, type,
strlen(type) + 1);
size_t toWrite = strlen(type) + 1;
ssize_t bytesWritten = _node.WriteAttr(kTypeAttr, B_STRING_TYPE, 0, type,
toWrite);
if (bytesWritten < 0)
error = bytesWritten;
else if ((size_t)bytesWritten != toWrite)
error = B_FILE_ERROR;
if (error != B_OK) {
_node.Unset();
return error;