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

Commit 9695342f authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Add boundary check for SparseTable."

parents cbed462d ef665816
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,12 @@ uint32_t SparseTable::get(const int id) const {
    const int indexTableReadingPos = getPosInIndexTable(id);
    const int index = mIndexTableBuffer->readUint(INDEX_SIZE, indexTableReadingPos);
    const int contentTableReadingPos = getPosInContentTable(id, index);
    if (contentTableReadingPos < 0
            || contentTableReadingPos >= mContentTableBuffer->getTailPosition()) {
        AKLOGE("contentTableReadingPos(%d) is invalid. id: %d, index: %d",
                contentTableReadingPos, id, index);
        return NOT_A_DICT_POS;
    }
    const int contentValue = mContentTableBuffer->readUint(mDataSize, contentTableReadingPos);
    return contentValue == NOT_EXIST ? NOT_A_DICT_POS : contentValue;
}