Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0941534 authored by Yujie Qin's avatar Yujie Qin Committed by Android (Google) Code Review
Browse files

Merge "Report error correctly for the implementation of StreamInterface::GetData()" into nyc-dev

parents db81dd9d cad16668
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -68,8 +68,12 @@ piex::Error BufferedStream::GetData(
        if (sizeToRead <= kMinSizeToRead) {
            sizeToRead = kMinSizeToRead;
        }

        void* tempBuffer = malloc(sizeToRead);
        if (tempBuffer != NULL) {
        if (tempBuffer == NULL) {
          return piex::Error::kFail;
        }

        size_t bytesRead = mStream->read(tempBuffer, sizeToRead);
        if (bytesRead != sizeToRead) {
            free(tempBuffer);
@@ -78,7 +82,6 @@ piex::Error BufferedStream::GetData(
        mStreamBuffer.write(tempBuffer, bytesRead);
        free(tempBuffer);
    }
    }

    // Read bytes.
    if (mStreamBuffer.read((void*)data, offset, length)) {
@@ -126,8 +129,8 @@ piex::Error FileStream::GetData(
    size_t size = fread((void*)data, sizeof(std::uint8_t), length, mFile);
    mPosition += size;

    // Handle errors.
    if (ferror(mFile)) {
    // Handle errors and verify the size.
    if (ferror(mFile) || size != length) {
        ALOGV("GetData read failed: (offset: %zu, length: %zu)", offset, length);
        return piex::Error::kFail;
    }