diff --git a/services/core/jni/com_android_server_GraphicsStatsService.cpp b/services/core/jni/com_android_server_GraphicsStatsService.cpp index 5d5728da61af2..61c53e6d30b31 100644 --- a/services/core/jni/com_android_server_GraphicsStatsService.cpp +++ b/services/core/jni/com_android_server_GraphicsStatsService.cpp @@ -43,8 +43,9 @@ static void addToDump(JNIEnv* env, jobject, jlong dumpPtr, jstring jpath, jstrin std::string path; const ProfileData* data = nullptr; LOG_ALWAYS_FATAL_IF(jdata == nullptr && jpath == nullptr, "Path and data can't both be null"); + ScopedByteArrayRO buffer{env}; if (jdata != nullptr) { - ScopedByteArrayRO buffer(env, jdata); + buffer.reset(jdata); LOG_ALWAYS_FATAL_IF(buffer.size() != sizeof(ProfileData), "Buffer size %zu doesn't match expected %zu!", buffer.size(), sizeof(ProfileData)); data = reinterpret_cast(buffer.get());