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

Commit a4530cea authored by Steven Moreland's avatar Steven Moreland
Browse files

Parcel: remove use of getOpenAshmemSize

Parcel native pointers are created when the Parcel is created, and they
are destroyed in finalize. When a Java object is finalized, we shouldn't
be calling methods on this (note - due to the way that compareData is
written, it will throw NPE if otherParcel is null - and if this were not
the case, the use of getOpenAshmemSize here - which will frequently be
zero - would break the comparison here).

Bug: 195752513
Test: atest android.os.ParcelTest android.os.cts.ParcelTest
Change-Id: Iad86624d6e0aad2ca37273ddbcb456dff7f48d46
parent c03b0fa0
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -596,13 +596,10 @@ static jint android_os_Parcel_compareData(JNIEnv* env, jclass clazz, jlong thisN
                                          jlong otherNativePtr)
{
    Parcel* thisParcel = reinterpret_cast<Parcel*>(thisNativePtr);
    if (thisParcel == NULL) {
       return 0;
    }
    LOG_ALWAYS_FATAL_IF(thisParcel == nullptr, "Should not be null");

    Parcel* otherParcel = reinterpret_cast<Parcel*>(otherNativePtr);
    if (otherParcel == NULL) {
       return thisParcel->getOpenAshmemSize();
    }
    LOG_ALWAYS_FATAL_IF(otherParcel == nullptr, "Should not be null");

    return thisParcel->compareData(*otherParcel);
}