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

Commit 61c83317 authored by Alex Klyubin's avatar Alex Klyubin
Browse files

readAt can return negative values (error codes).

This fixes the regression introduced in
59cea261 due to which MediaPlayer
treated all error codes returned by MediaHTTPConnection as
ERROR_OUT_OF_RANGE.

The regression was caused by accidentally converting negative values
(which represent error codes) returned by MediaHTTPConnection to very
large positive ones (which represent length of data received).

Bug: 21922241
Change-Id: I1b4592b5fec724aac1ba6c1ff8fdabcba56bcd2d
parent 3fc792fe
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -107,7 +107,14 @@ struct BpMediaHTTPConnection : public BpInterface<IMediaHTTPConnection> {
            return UNKNOWN_ERROR;
        }

        size_t len = reply.readInt32();
        int32_t lenOrErrorCode = reply.readInt32();

        // Negative values are error codes
        if (lenOrErrorCode < 0) {
            return lenOrErrorCode;
        }

        size_t len = lenOrErrorCode;

        if (len > size) {
            ALOGE("requested %zu, got %zu", size, len);