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

Commit 76872602 authored by Shai Barack's avatar Shai Barack
Browse files

Fix SharedMemory.MemoryRegistration.size calculation when PAGE_SIZE is 0.

This value can be zero in Robolectric host tests.

Bug: 363006031
Change-Id: I5f162b829e4307a9ef3281d52d8c7c416e116ede
Flag: EXEMPT bugfix
parent 9a6338cd
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -381,10 +381,12 @@ public final class SharedMemory implements Parcelable, Closeable {
        private MemoryRegistration(int size) {
            // Round up to the nearest page size
            final int PAGE_SIZE = OsConstants._SC_PAGE_SIZE;
            if (PAGE_SIZE > 0) {
                final int remainder = size % PAGE_SIZE;
                if (remainder != 0) {
                    size += PAGE_SIZE - remainder;
                }
            }
            mSize = size;
            mReferenceCount = 1;
            VMRuntime.getRuntime().registerNativeAllocation(mSize);