summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-12-08 17:15:50 -0800
committerColin Cross <ccross@android.com>2015-12-08 17:18:12 -0800
commit83ec65e19a8b5e1ae11e789b3d79d08543b09193 (patch)
tree5c017065ee6903c41d761c33ee20fd87fff48f09
parent18ff6557667f3d130ad1f83e04f3b175f8b8cf6d (diff)
downloadnative-83ec65e19a8b5e1ae11e789b3d79d08543b09193.tar.gz
Fix allocation count
The realloc case in continueWrite should not increment the counter, the pointer passed to realloc is guaranteed to be non-NULL so the total number of allocations will not have changed. When realloc is called in restartWrite mData has not been checked against NULL, increment the counter if it was NULL. Bug: 26086286 Change-Id: I4c8af450cca1868b91793c0c5f0d8c4b4b5badbe
-rw-r--r--libs/binder/Parcel.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 94968218e0..258557918d 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -1963,6 +1963,9 @@ status_t Parcel::restartWrite(size_t desired)
pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
gParcelGlobalAllocSize += desired;
gParcelGlobalAllocSize -= mDataCapacity;
+ if (!mData) {
+ gParcelGlobalAllocCount++;
+ }
pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
mData = data;
mDataCapacity = desired;
@@ -2094,7 +2097,6 @@ status_t Parcel::continueWrite(size_t desired)
pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
gParcelGlobalAllocSize += desired;
gParcelGlobalAllocSize -= mDataCapacity;
- gParcelGlobalAllocCount++;
pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
mData = data;
mDataCapacity = desired;