Merge "Fix missing Release for GetStringUTFChars calls." into tm-dev

This commit is contained in:
TreeHugger Robot
2022-04-23 02:50:04 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 6 deletions

View File

@@ -459,8 +459,12 @@ static jobject NativeGetOverlayableInfo(JNIEnv* env, jclass /*clazz*/, jlong ptr
return nullptr; return nullptr;
} }
auto overlayable_name_native = std::string(env->GetStringUTFChars(overlayable_name, NULL)); const char* overlayable_name_native = env->GetStringUTFChars(overlayable_name, nullptr);
if (overlayable_name_native == nullptr) {
return nullptr;
}
auto actor = overlayable_map.find(overlayable_name_native); auto actor = overlayable_map.find(overlayable_name_native);
env->ReleaseStringUTFChars(overlayable_name, overlayable_name_native);
if (actor == overlayable_map.end()) { if (actor == overlayable_map.end()) {
return nullptr; return nullptr;
} }

View File

@@ -48,6 +48,7 @@
#include <jni.h> #include <jni.h>
#include <nativehelper/JNIHelp.h> #include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedUtfChars.h>
using namespace android; using namespace android;
using namespace img_utils; using namespace img_utils;
@@ -1264,16 +1265,14 @@ static void DngCreator_init(JNIEnv* env, jobject thiz, jobject characteristicsPt
sp<NativeContext> nativeContext = new NativeContext(characteristics, results); sp<NativeContext> nativeContext = new NativeContext(characteristics, results);
const char* captureTime = env->GetStringUTFChars(formattedCaptureTime, nullptr); ScopedUtfChars captureTime(env, formattedCaptureTime);
if (captureTime.size() + 1 != NativeContext::DATETIME_COUNT) {
size_t len = strlen(captureTime) + 1;
if (len != NativeContext::DATETIME_COUNT) {
jniThrowException(env, "java/lang/IllegalArgumentException", jniThrowException(env, "java/lang/IllegalArgumentException",
"Formatted capture time string length is not required 20 characters"); "Formatted capture time string length is not required 20 characters");
return; return;
} }
nativeContext->setCaptureTime(String8(captureTime)); nativeContext->setCaptureTime(String8(captureTime.c_str()));
DngCreator_setNativeContext(env, thiz, nativeContext); DngCreator_setNativeContext(env, thiz, nativeContext);
} }