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

Commit 32591038 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

Fix the null data ptr in CursorWindow

The class implementation assumes this data pointer is never
null, even when there's no data - to optimize the accessor
functions.

Bug: 438359711
Test: build + atest libandroidfw_tests
Flag: EXEMPT small bugfix
Change-Id: I56386ea9d6ec0f2dac960e72ebdf826d18cd753b
parent 003b2bc6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -188,9 +188,9 @@ status_t CursorWindow::createFromParcel(Parcel* parcel, CursorWindow** outWindow
            goto fail_silent;
        }

        if (window->mSize > 0) {
        window->mData = malloc(window->mSize);
        if (!window->mData) goto fail;
        if (window->mSize > 0) {
            if (parcel->read(window->mData, window->mSize)) goto fail;
        }
    }
+5 −0
Original line number Diff line number Diff line
@@ -154,6 +154,11 @@ private:
    String8 mName;
    std::optional<android::base::MappedFile> mMappedFile;
    int mAshmemFd = -1;
    /**
     * Pointer to the start of the memory region, either mmap'ed from ashmem, or malloc'ed.
     * Must not be null after full initialization even for an empty window, as many getters perform
     * pointer arithmetic on it without null checks for performance reasons.
     */
    void* mData = nullptr;
    /**
     * Pointer to the first FieldSlot, used to optimize the extremely