diff options
| author | 2015-09-10 22:20:22 +0000 | |
|---|---|---|
| committer | 2015-09-10 22:20:22 +0000 | |
| commit | 6ffcb0097e5f000eda39f12f91766a27d772e120 (patch) | |
| tree | 8bf895436df9f67201367d35829e53a56258793f /libs/binder/Parcel.cpp | |
| parent | 4107f8fc7c077591fa8ce4b7e13f135424f27a15 (diff) | |
| parent | 0823223c6fa6b97fd15d11de5ddb38b21fccf2de (diff) | |
am 0823223c: am f0f131f3: am 6c8c8138: Merge "Benign unsigned integer overflow in Parcel"
* commit '0823223c6fa6b97fd15d11de5ddb38b21fccf2de':
  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;  |