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

Commit 1d12419f authored by Marco Nelissen's avatar Marco Nelissen Committed by android-build-merger
Browse files

Make VBRISeeker more robust am: 7fdd3641 am: ae0cffac am: 82642824 am:...

Make VBRISeeker more robust am: 7fdd3641 am: ae0cffac am: 82642824 am: c236ae3a am: 43dad372 am: aa8c778d am: a0b2e168 am: 443a1aa7 am: 1b0f31aa am: 0465a2c2
am: 93c02f84

Change-Id: I41cd3d797f6846fa16f18bdd4fcfa2903612309a
parents 0359f83b 93c02f84
Loading
Loading
Loading
Loading
+16 −2
Original line number Original line Diff line number Diff line
@@ -83,8 +83,23 @@ sp<VBRISeeker> VBRISeeker::CreateFromSource(
         scale,
         scale,
         entrySize);
         entrySize);


    if (entrySize > 4) {
        ALOGE("invalid VBRI entry size: %zu", entrySize);
        return NULL;
    }

    sp<VBRISeeker> seeker = new (std::nothrow) VBRISeeker;
    if (seeker == NULL) {
        ALOGW("Couldn't allocate VBRISeeker");
        return NULL;
    }

    size_t totalEntrySize = numEntries * entrySize;
    size_t totalEntrySize = numEntries * entrySize;
    uint8_t *buffer = new uint8_t[totalEntrySize];
    uint8_t *buffer = new (std::nothrow) uint8_t[totalEntrySize];
    if (!buffer) {
        ALOGW("Couldn't allocate %zu bytes", totalEntrySize);
        return NULL;
    }


    n = source->readAt(pos + sizeof(vbriHeader), buffer, totalEntrySize);
    n = source->readAt(pos + sizeof(vbriHeader), buffer, totalEntrySize);
    if (n < (ssize_t)totalEntrySize) {
    if (n < (ssize_t)totalEntrySize) {
@@ -94,7 +109,6 @@ sp<VBRISeeker> VBRISeeker::CreateFromSource(
        return NULL;
        return NULL;
    }
    }


    sp<VBRISeeker> seeker = new VBRISeeker;
    seeker->mBasePos = post_id3_pos + frameSize;
    seeker->mBasePos = post_id3_pos + frameSize;
    // only update mDurationUs if the calculated duration is valid (non zero)
    // only update mDurationUs if the calculated duration is valid (non zero)
    // otherwise, leave duration at -1 so that getDuration() and getOffsetForTime()
    // otherwise, leave duration at -1 so that getDuration() and getOffsetForTime()