diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-13 02:15:45 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-12-13 02:15:45 +0100 |
commit | d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18 (patch) | |
tree | a21f7d76365795800eebfd006d34803a9304e04c /libs/binder/IMemory.cpp | |
parent | b2381c3e4b90d845d9713b7b29d64317b7f21ce8 (diff) | |
parent | b22bca465e55618a949d9cbdea665a1a3a831241 (diff) | |
download | frameworks_native-d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18.zip frameworks_native-d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18.tar.gz frameworks_native-d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18.tar.bz2 |
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_frameworks_native into replicant-6.0
Diffstat (limited to 'libs/binder/IMemory.cpp')
-rw-r--r-- | libs/binder/IMemory.cpp | 18 |
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; } // --------------------------------------------------------------------------- |