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

Commit af6b6652 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Ensure to release local reference in AppFuse JNI.

Previously get_object_bytes() leaked local reference of Java buffer
array.

BUG=None

Change-Id: Ic27e57281f984fee4aa285ad21de522ccb0fe4ed
parent 5becd423
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "nativehelper/ScopedPrimitiveArray.h"
#include "nativehelper/ScopedLocalRef.h"

namespace {

@@ -334,16 +335,16 @@ private:
        const uint32_t read_size = static_cast<uint32_t>(std::min(
                static_cast<uint64_t>(size),
                get_file_size(inode) - offset));
        const jbyteArray array = (jbyteArray) env_->CallObjectMethod(
        ScopedLocalRef<jbyteArray> array(env_, static_cast<jbyteArray>(env_->CallObjectMethod(
                self_,
                app_fuse_get_object_bytes,
                inode,
                offset,
                read_size);
        if (array == nullptr) {
                read_size)));
        if (array.get() == nullptr) {
            return -1;
        }
        ScopedByteArrayRO bytes(env_, array);
        ScopedByteArrayRO bytes(env_, array.get());
        if (bytes.size() != read_size || bytes.get() == nullptr) {
            return -1;
        }