summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-04-05 17:10:29 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-04-05 17:10:29 +0000
commite59437a40e278fdaa69f1bf54cd6702a96a644a2 (patch)
treedca577ffe3a94c4fc73c8804044ec2cbfcb9d2de /libs/binder/Parcel.cpp
parent97589e43b7060879322f287c1f9904f33b0abd1a (diff)
parent1fda67b02a7d3b78c1c3ee92734e096715190a14 (diff)
Merge changes Ibdbe8161,Id2b0fc02
* changes: libbinder: ensure entire Parcel is the same format libbinder: RPC avoid copy of transaction data
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 34a474b252..3f0b0df4f6 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -555,12 +555,17 @@ void Parcel::markSensitive() const
}
void Parcel::markForBinder(const sp<IBinder>& binder) {
+ LOG_ALWAYS_FATAL_IF(mData != nullptr, "format must be set before data is written");
+
if (binder && binder->remoteBinder() && binder->remoteBinder()->isRpcBinder()) {
markForRpc(binder->remoteBinder()->getPrivateAccessorForId().rpcConnection());
}
}
void Parcel::markForRpc(const sp<RpcConnection>& connection) {
+ LOG_ALWAYS_FATAL_IF(mData != nullptr && mOwner == nullptr,
+ "format must be set before data is written OR on IPC data");
+
LOG_ALWAYS_FATAL_IF(connection == nullptr, "markForRpc requires connection");
mConnection = connection;
}
@@ -2100,6 +2105,9 @@ size_t Parcel::ipcObjectsCount() const
void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
const binder_size_t* objects, size_t objectsCount, release_func relFunc)
{
+ // this code uses 'mOwner == nullptr' to understand whether it owns memory
+ LOG_ALWAYS_FATAL_IF(relFunc == nullptr, "must provide cleanup function");
+
freeData();
mData = const_cast<uint8_t*>(data);