summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-29 23:31:34 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-08-29 23:31:34 +0000
commitb7ab38e10e1f0d3088153f070e681e34263d393c (patch)
tree8c2050af48857eab07fb03c23b35dbce8c861683
parentec3810476fa9f0a3e1e7472bc7e2e6c5dba5ed04 (diff)
parent76872602c5661fcb97ab6baabe086f5773775def (diff)
Merge "Fix SharedMemory.MemoryRegistration.size calculation when PAGE_SIZE is 0." into main
-rw-r--r--core/java/android/os/SharedMemory.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/java/android/os/SharedMemory.java b/core/java/android/os/SharedMemory.java
index a15b3bbd9b4e..46ae9d8682ee 100644
--- a/core/java/android/os/SharedMemory.java
+++ b/core/java/android/os/SharedMemory.java
@@ -381,9 +381,11 @@ 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;
- final int remainder = size % PAGE_SIZE;
- if (remainder != 0) {
- size += PAGE_SIZE - remainder;
+ if (PAGE_SIZE > 0) {
+ final int remainder = size % PAGE_SIZE;
+ if (remainder != 0) {
+ size += PAGE_SIZE - remainder;
+ }
}
mSize = size;
mReferenceCount = 1;