diff options
| author | 2015-09-10 22:12:56 +0000 | |
|---|---|---|
| committer | 2015-09-10 22:12:56 +0000 | |
| commit | 0823223c6fa6b97fd15d11de5ddb38b21fccf2de (patch) | |
| tree | 852eda23710be22c42bf97f6e386144586974a7c /libs/binder/Parcel.cpp | |
| parent | 1769e697542bd5fac2014bb7eb15210e6cdc20d3 (diff) | |
| parent | f0f131f36b5ce2a25992576aa75e7c08654e5a8d (diff) | |
am f0f131f3: am 6c8c8138: Merge "Benign unsigned integer overflow in Parcel"
* commit 'f0f131f36b5ce2a25992576aa75e7c08654e5a8d':
Benign unsigned integer overflow in Parcel
Diffstat (limited to 'libs/binder/Parcel.cpp')
| -rw-r--r-- | libs/binder/Parcel.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 7a4ddc43a5..45191f5bd9 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -1645,8 +1645,14 @@ void Parcel::freeDataNoInit() if (mData) { LOG_ALLOC("Parcel %p: freeing with %zu capacity", this, mDataCapacity); pthread_mutex_lock(&gParcelGlobalAllocSizeLock); - gParcelGlobalAllocSize -= mDataCapacity; - gParcelGlobalAllocCount--; + if (mDataCapacity <= gParcelGlobalAllocSize) { + gParcelGlobalAllocSize = gParcelGlobalAllocSize - mDataCapacity; + } else { + gParcelGlobalAllocSize = 0; + } + if (gParcelGlobalAllocCount > 0) { + gParcelGlobalAllocCount--; + } pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); free(mData); } @@ -1825,6 +1831,7 @@ status_t Parcel::continueWrite(size_t desired) pthread_mutex_lock(&gParcelGlobalAllocSizeLock); gParcelGlobalAllocSize += desired; gParcelGlobalAllocSize -= mDataCapacity; + gParcelGlobalAllocCount++; pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); mData = data; mDataCapacity = desired; |