From 3bdecbf0fd2d4b6137477094e1ea96502c353248 Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 14 Nov 2016 11:28:17 -0800 Subject: [PATCH] return 0 for allocation size if recycled Change-Id: Ic471701faf026411938ebe87131533a8ef09bbd7 Fixes: 19804653 Test: none --- graphics/java/android/graphics/Bitmap.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 79c63ee306af4..e628cf8af89da 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -1241,6 +1241,11 @@ public final class Bitmap implements Parcelable { * #getAllocationByteCount()}.

*/ public final int getByteCount() { + if (mRecycled) { + Log.w(TAG, "Called getByteCount() on a recycle()'d bitmap! " + + "This is undefined behavior!"); + return 0; + } // int result permits bitmaps up to 46,340 x 46,340 return getRowBytes() * getHeight(); } @@ -1260,6 +1265,11 @@ public final class Bitmap implements Parcelable { * @see #reconfigure(int, int, Config) */ public final int getAllocationByteCount() { + if (mRecycled) { + Log.w(TAG, "Called getAllocationByteCount() on a recycle()'d bitmap! " + + "This is undefined behavior!"); + return 0; + } return nativeGetAllocationByteCount(mNativePtr); }