diff --git a/src/kits/support/DataIO.cpp b/src/kits/support/DataIO.cpp index ea427828fe..7dd3f3b3fd 100644 --- a/src/kits/support/DataIO.cpp +++ b/src/kits/support/DataIO.cpp @@ -341,16 +341,18 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size) size_t newSize = max(pos + size, static_cast(fLength)); - if (newSize > fMallocSize) - if (SetSize(newSize) != B_OK) - size = 0; + status_t error = B_OK; - if (size > 0) { + if (newSize > fMallocSize) + error = SetSize(newSize); + + if (error == B_OK) { memcpy(fData + pos, buffer, size); if (pos + size > fLength) fLength = pos + size; } - return size; + + return error != B_OK ? error : size; }