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

Commit 0dd4df27 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "If the codec's input buffer size is too small to accomodate the buffer...

Merge "If the codec's input buffer size is too small to accomodate the buffer read from the source, report and error instead of asserting."
parents 632aa764 42c444a8
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ static const CodecInfo kEncoderInfo[] = {

#define CODEC_LOGI(x, ...) LOGI("[%s] "x, mComponentName, ##__VA_ARGS__)
#define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__)
#define CODEC_LOGE(x, ...) LOGE("[%s] "x, mComponentName, ##__VA_ARGS__)

struct OMXCodecObserver : public BnOMXObserver {
    OMXCodecObserver() {
@@ -1931,10 +1932,17 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
        srcLength = srcBuffer->range_length();

        if (info->mSize < srcLength) {
            LOGE("info->mSize = %d, srcLength = %d",
            CODEC_LOGE(
                 "Codec's input buffers are too small to accomodate "
                 "buffer read from source (info->mSize = %d, srcLength = %d)",
                 info->mSize, srcLength);

            srcBuffer->release();
            srcBuffer = NULL;

            setState(ERROR);
            return;
        }
        CHECK(info->mSize >= srcLength);
        memcpy(info->mData,
               (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(),
               srcLength);