summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-01-23 20:33:18 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-01-23 20:33:18 +0000
commit1e5dd46133bd47445ba0657692fb86492acad705 (patch)
tree8746f60f646d051be45329f1ccb873b48070c06f /graphics
parent2fd1a8b6ca93a99c083a3269ae69ae7d67701a8b (diff)
parentbb8d7ffeae187e8782a9494e252e335db537b2a1 (diff)
downloadframeworks_base-1e5dd46133bd47445ba0657692fb86492acad705.zip
frameworks_base-1e5dd46133bd47445ba0657692fb86492acad705.tar.gz
frameworks_base-1e5dd46133bd47445ba0657692fb86492acad705.tar.bz2
am 94474515: Merge "Prevent memory corruption from use-after-free" into lmp-mr1-dev
automerge: bb8d7ff * commit 'bb8d7ffeae187e8782a9494e252e335db537b2a1': Prevent memory corruption from use-after-free
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/Bitmap.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 3f79c2d..72f6118 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -304,7 +304,7 @@ public final class Bitmap implements Parcelable {
* there are no more references to this bitmap.
*/
public void recycle() {
- if (!mRecycled) {
+ if (!mRecycled && mFinalizer.mNativeBitmap != 0) {
if (nativeRecycle(mNativeBitmap)) {
// return value indicates whether native pixel object was actually recycled.
// false indicates that it is still in use at the native level and these
@@ -1571,7 +1571,7 @@ public final class Bitmap implements Parcelable {
}
private static class BitmapFinalizer {
- private final long mNativeBitmap;
+ private long mNativeBitmap;
// Native memory allocated for the duration of the Bitmap,
// if pixel data allocated into native memory, instead of java byte[]
@@ -1597,6 +1597,7 @@ public final class Bitmap implements Parcelable {
VMRuntime.getRuntime().registerNativeFree(mNativeAllocationByteCount);
}
nativeDestructor(mNativeBitmap);
+ mNativeBitmap = 0;
}
}
}