diff options
| author | 2023-05-17 14:54:47 +0900 | |
|---|---|---|
| committer | 2023-05-22 09:38:40 -0700 | |
| commit | 06aaf05f00c32f5421ee3c97587055ab45f36d9b (patch) | |
| tree | d8942eb42b942282d58afbc603da93fbe7408554 /graphics/java/android | |
| parent | ecbd3d61dd136c1d4f53509e476c98b800752a7d (diff) | |
Camera: Address an issue that the invalid memory is accessed
If the ImagePlanes is initiailized the HardwareBuffer and is close()'ed
by finalizer then the invalid memory access to the GraphicBufferWrapper
and GraphicBuffer could be happen.
This patch addressed the issue by properly clearing fields after
being destoyed.
Bug: 283038375
Test: Test extensions proxy service with advanced extender
implementation while maintaining a reference counter so that the
ExtensionImage is finalized without invoking close.
Change-Id: Iab49da708daf0099d029cda6873cb2e811377fbc
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/GraphicBuffer.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/GraphicBuffer.java b/graphics/java/android/graphics/GraphicBuffer.java index f9113a21405c..6705b25ab0ec 100644 --- a/graphics/java/android/graphics/GraphicBuffer.java +++ b/graphics/java/android/graphics/GraphicBuffer.java @@ -57,7 +57,7 @@ public class GraphicBuffer implements Parcelable { private final int mUsage; // Note: do not rename, this field is used by native code @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - private final long mNativeObject; + private long mNativeObject; // These two fields are only used by lock/unlockCanvas() private Canvas mCanvas; @@ -219,6 +219,7 @@ public class GraphicBuffer implements Parcelable { if (!mDestroyed) { mDestroyed = true; nDestroyGraphicBuffer(mNativeObject); + mNativeObject = 0; } } @@ -239,7 +240,7 @@ public class GraphicBuffer implements Parcelable { @Override protected void finalize() throws Throwable { try { - if (!mDestroyed) nDestroyGraphicBuffer(mNativeObject); + destroy(); } finally { super.finalize(); } |