Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64ff3866 authored by Jintao Zhu's avatar Jintao Zhu Committed by Jintao Zhu
Browse files

Parcel: noop upon double recycle



Fix this scenario:

  Parcel p = Parcel.obtain();
  p.recycle();
  p.recycle(); // illegal but possible

  Parcel p1 = Parcel.obtain();
  Parcel p2 = Parcel.obtain();

  ASSERT_TRUE(p1 != p2); // fail!

Signed-off-by: default avatarJintao Zhu <zhu.jintao@gm.com>

Change-Id: Ied25188549801122874a05c2e66969e1f281b346
parent 90a441ea
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -560,9 +560,11 @@ public final class Parcel {
     */
    public final void recycle() {
        if (mRecycled) {
            Log.w(TAG, "Recycle called on unowned Parcel. (recycle twice?) Here: "
            Log.wtf(TAG, "Recycle called on unowned Parcel. (recycle twice?) Here: "
                    + Log.getStackTraceString(new Throwable())
                    + " Original recycle call (if DEBUG_RECYCLE): ", mStack);

            return;
        }
        mRecycled = true;