From 713c258edc79fe6402a57d3c038d964da0dae6fe Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Thu, 16 Dec 2021 01:03:54 +0000 Subject: [PATCH] Binder: recycle Parcel in finally block If other types of exceptions happen here, we should still recycle the Parcel. Bug: 207778694 Test: boot Change-Id: I3375b87a674c45f8bc66848dfaf899497f5acaa8 --- core/java/android/os/Binder.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index b069fb336d55c..59db8f495dd9b 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -1235,10 +1235,11 @@ public class Binder implements IBinder { data.readCallingWorkSourceUid()); observer.callEnded(callSession, data.dataSize(), reply.dataSize(), workSourceUid); } + + checkParcel(this, code, reply, "Unreasonably large binder reply buffer"); + reply.recycle(); + data.recycle(); } - checkParcel(this, code, reply, "Unreasonably large binder reply buffer"); - reply.recycle(); - data.recycle(); // Just in case -- we are done with the IPC, so there should be no more strict // mode violations that have gathered for this thread. Either they have been