diff options
| -rw-r--r-- | libs/binder/Parcel.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index b2db945af0..0423264135 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -181,7 +181,10 @@ static void release_object(const sp<ProcessState>& proc, if ((outAshmemSize != nullptr) && ashmem_valid(obj.handle)) { int size = ashmem_get_size_region(obj.handle); if (size > 0) { - *outAshmemSize -= size; + // ashmem size might have changed since last time it was accounted for, e.g. + // in acquire_object(). Value of *outAshmemSize is not critical since we are + // releasing the object anyway. Check for integer overflow condition. + *outAshmemSize -= std::min(*outAshmemSize, static_cast<size_t>(size)); } } |