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

Commit 44390105 authored by T.J. Mercier's avatar T.J. Mercier
Browse files

Fix memory leak of lastArray when newArray == NULL

lastArray remains copied/pinned when android_os_Process_getPids returns
early because of a failure to allocate newArray.

Bug: 351917521
Test: cuttlefish boot
Change-Id: I95ebeb36ffc185a21acca11b9393b6dd8f4e0f83
parent ec5dcca5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -818,7 +818,6 @@ jintArray android_os_Process_getPids(JNIEnv* env, jobject clazz,
    }

    DIR* dirp = opendir(file8);

    env->ReleaseStringUTFChars(file, file8);

    if(dirp == NULL) {
@@ -851,6 +850,7 @@ jintArray android_os_Process_getPids(JNIEnv* env, jobject clazz,
            jintArray newArray = env->NewIntArray(newCount);
            if (newArray == NULL) {
                closedir(dirp);
                if (curData) env->ReleaseIntArrayElements(lastArray, curData, 0);
                jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
                return NULL;
            }