summaryrefslogtreecommitdiff
path: root/graphics/java
diff options
context:
space:
mode:
author Cuiping.x.Shu <cuiping.x.shu@sony.com> 2017-11-22 13:30:31 +0800
committer Xiong Li <xiong.li@sony.com> 2019-02-23 00:09:26 +0000
commit0a5c8c15ebc0cfbca8fca6cea684e17c66d73284 (patch)
tree53fbc69f6789f57c53b6166e384fa873dfdd4a1b /graphics/java
parent037a0879c0ca67dc1f52f1d9a449d47c48197d45 (diff)
Check recycled when createBitmap
This is to avoid framework crash when application used the recycled bitmap memory in createBitmap. Bug:123656975 Change-Id: I98f93ce48c7bc91913d0b31bca1dc0a10eb319d7
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/Bitmap.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index d6131cf2e5d4..507f767ae3e6 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -814,7 +814,7 @@ public final class Bitmap implements Parcelable {
* @return A bitmap that represents the specified subset of source
* @throws IllegalArgumentException if the x, y, width, height values are
* outside of the dimensions of the source bitmap, or width is <= 0,
- * or height is <= 0
+ * or height is <= 0, or if the source bitmap has already been recycled
*/
public static Bitmap createBitmap(@NonNull Bitmap source, int x, int y, int width, int height,
@Nullable Matrix m, boolean filter) {
@@ -827,6 +827,9 @@ public final class Bitmap implements Parcelable {
if (y + height > source.getHeight()) {
throw new IllegalArgumentException("y + height must be <= bitmap.height()");
}
+ if (source.isRecycled()) {
+ throw new IllegalArgumentException("cannot use a recycled source in createBitmap");
+ }
// check if we can just return our argument unchanged
if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() &&