summaryrefslogtreecommitdiffstats
path: root/libs/binder/IMemory.cpp
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@cyngn.com>2016-04-05 12:31:30 -0700
committerJessica Wagantall <jwagantall@cyngn.com>2016-04-05 12:31:30 -0700
commit31d9cccf23017fa67532001e737a4660ec39febc (patch)
treea9072caebf7ff7e0cbfc03c2ba60e63ceb00e100 /libs/binder/IMemory.cpp
parent65a4c0c045185e8bf5ad54ef8db2a3dbbf6c2813 (diff)
parentad2ddfd372d35d061197b51e6f89b7a490256414 (diff)
downloadframeworks_native-31d9cccf23017fa67532001e737a4660ec39febc.zip
frameworks_native-31d9cccf23017fa67532001e737a4660ec39febc.tar.gz
frameworks_native-31d9cccf23017fa67532001e737a4660ec39febc.tar.bz2
Merge tag 'android-6.0.1_r24' into HEAD
Ticket: CYNGNOS-2213 Android 6.0.1 release 24
Diffstat (limited to 'libs/binder/IMemory.cpp')
-rw-r--r--libs/binder/IMemory.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp
index 3f2198a..f59867a 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -26,6 +26,7 @@
#include <sys/mman.h>
#include <binder/IMemory.h>
+#include <cutils/log.h>
#include <utils/KeyedVector.h>
#include <utils/threads.h>
#include <utils/Atomic.h>
@@ -191,15 +192,26 @@ sp<IMemoryHeap> BpMemory::getMemory(ssize_t* offset, size_t* size) const
if (heap != 0) {
mHeap = interface_cast<IMemoryHeap>(heap);
if (mHeap != 0) {
- mOffset = o;
- mSize = s;
+ size_t heapSize = mHeap->getSize();
+ if (s <= heapSize
+ && o >= 0
+ && (static_cast<size_t>(o) <= heapSize - s)) {
+ mOffset = o;
+ mSize = s;
+ } else {
+ // Hm.
+ android_errorWriteWithInfoLog(0x534e4554,
+ "26877992", -1, NULL, 0);
+ mOffset = 0;
+ mSize = 0;
+ }
}
}
}
}
if (offset) *offset = mOffset;
if (size) *size = mSize;
- return mHeap;
+ return (mSize > 0) ? mHeap : 0;
}
// ---------------------------------------------------------------------------