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

Commit f26b005c authored by Steven Moreland's avatar Steven Moreland
Browse files

Slice: avoid OOM on read

This avoids allocating a size which is read in from another process, which can cause OOM conditions and a crash.

Bug: 370353559
Change-Id: I906772e32f07f122889e4d3533167fea57b29aa4
Test: TH
parent 31b8de43
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -273,11 +273,7 @@ public final class Slice implements Parcelable {

    protected Slice(Parcel in) {
        mHints = in.readStringArray();
        int n = in.readInt();
        mItems = new SliceItem[n];
        for (int i = 0; i < n; i++) {
            mItems[i] = SliceItem.CREATOR.createFromParcel(in);
        }
        mItems = in.createTypedArray(SliceItem.CREATOR);
        mUri = Uri.CREATOR.createFromParcel(in);
        mSpec = in.readTypedObject(SliceSpec.CREATOR);
    }
@@ -313,10 +309,7 @@ public final class Slice implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStringArray(mHints);
        dest.writeInt(mItems.length);
        for (int i = 0; i < mItems.length; i++) {
            mItems[i].writeToParcel(dest, flags);
        }
        dest.writeTypedArray(mItems, flags);
        mUri.writeToParcel(dest, 0);
        dest.writeTypedObject(mSpec, flags);
    }