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:
@@ -114,8 +114,14 @@ DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
// write the type attribute
|
// write the type attribute
|
||||||
error = _node.WriteAttr(kTypeAttr, B_STRING_TYPE, 0, type,
|
size_t toWrite = strlen(type) + 1;
|
||||||
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) {
|
if (error != B_OK) {
|
||||||
_node.Unset();
|
_node.Unset();
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
Reference in New Issue
Block a user