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

Commit ad3cc3c6 authored by Hans Boehm's avatar Hans Boehm
Browse files

Clear more native pointers in finalizers

This hopefully handles the remaining finalizers in frameworks/base
that didn't guard against calls from other finalizers after being
finalized.

The goal here is to reduce the possible corruption causes we have
to think about by a few.

If any of theses are either very frequently used, or use large
Java (as opposed to native) objects, we should probably convert them
to NativeAllocationRegistry instead. But that's more work.

Bug: 18178237
Change-Id: I79bc0e8fa20af8f340418a6226022e0294d77f02
parent 4c7169fa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ public class Camera {
    protected void finalize() throws Throwable {
        try {
            nativeDestructor();
            native_instance = 0;
        } finally {
            super.finalize();
        }
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class ColorFilter {
            super.finalize();
        } finally {
            destroyFilter(native_instance);
            native_instance = 0;
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public class DrawFilter {
    protected void finalize() throws Throwable {
        try {
            nativeDestructor(mNativeInt);
            mNativeInt = 0;
        } finally {
            super.finalize();
        }
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import java.io.InputStream;
import java.io.FileInputStream;

public class Movie {
    private final long mNativeMovie;
    private long mNativeMovie;

    private Movie(long nativeMovie) {
        if (nativeMovie == 0) {
@@ -82,6 +82,7 @@ public class Movie {
    protected void finalize() throws Throwable {
        try {
            nativeDestructor(mNativeMovie);
            mNativeMovie = 0;
        } finally {
            super.finalize();
        }
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ public class Rasterizer {

    protected void finalize() throws Throwable {
        finalizer(native_instance);
        native_instance = 0;
    }

    private static native void finalizer(long native_instance);
Loading