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

Commit fe5cd492 authored by Iris Chang's avatar Iris Chang Committed by Marco Nelissen
Browse files

Fix native exception caused by memset 0 to NULL pointer

When memory is not enough, it will fail to allocate mSampleTimeEntries
and it will return NULL. So memset will set 0 to address 0x00, and
exception occurs.

Bug: 143057966
Test: this is a seldom issue and we analyze this exception by callstack
Change-Id: Ia69884a984c8d38e58b325b4043977e6e196e6a2
parent 4cb250e1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -655,12 +655,13 @@ void SampleTable::buildSampleEntriesTable() {
    }

    mSampleTimeEntries = new (std::nothrow) SampleTimeEntry[mNumSampleSizes];
    memset(mSampleTimeEntries, 0, sizeof(SampleTimeEntry) * mNumSampleSizes);

    if (!mSampleTimeEntries) {
        ALOGE("Cannot allocate sample entry table with %llu entries.",
                (unsigned long long)mNumSampleSizes);
        return;
    }
    memset(mSampleTimeEntries, 0, sizeof(SampleTimeEntry) * mNumSampleSizes);

    uint32_t sampleIndex = 0;
    uint64_t sampleTime = 0;