From eff77c1f4c9a2fb22f0c90dc4710dda178315996 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Thu, 15 Apr 2021 00:37:19 +0000 Subject: libbinder: scope down Parcel data in RPC transact We don't need (or want) to do more stuff in an error case. Bug: 167966510 Test: binderRpcTest Change-Id: I7a0b0b7f6b68c2fbd22f52b3888a9ed7b3179467 --- libs/binder/RpcState.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'libs/binder/RpcState.cpp') diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 755ff35781..9d597f92db 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -498,19 +498,20 @@ status_t RpcState::processTransactInternal(const base::unique_fd& fd, } } - Parcel data; - // transaction->data is owned by this function. Parcel borrows this data and - // only holds onto it for the duration of this function call. Parcel will be - // deleted before the 'transactionData' object. - data.ipcSetDataReference(transaction->data, - transactionData.size() - offsetof(RpcWireTransaction, data), - nullptr /*object*/, 0 /*objectCount*/, do_nothing_to_transact_data); - data.markForRpc(connection); - Parcel reply; reply.markForRpc(connection); if (replyStatus == OK) { + Parcel data; + // transaction->data is owned by this function. Parcel borrows this data and + // only holds onto it for the duration of this function call. Parcel will be + // deleted before the 'transactionData' object. + data.ipcSetDataReference(transaction->data, + transactionData.size() - offsetof(RpcWireTransaction, data), + nullptr /*object*/, 0 /*objectCount*/, + do_nothing_to_transact_data); + data.markForRpc(connection); + if (target) { replyStatus = target->transact(transaction->code, data, &reply, transaction->flags); } else { -- cgit v1.2.3-59-g8ed1b