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

Commit 813714c2 authored by Christopher Ferris's avatar Christopher Ferris Committed by Elliott Hughes
Browse files

Fix missing Release for GetStringUTFChars calls.

Bug: 230122201

Test: No leaks detected in these code paths.
Test: atest android.hardware.camera2.cts.DngCreatorTest on pixel 6 Pro.
Change-Id: I135739b9e65a57c3d130c35fcdf4ffd1ec4786c0
parent 3f28fc99
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -459,8 +459,12 @@ static jobject NativeGetOverlayableInfo(JNIEnv* env, jclass /*clazz*/, jlong ptr
    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);
  env->ReleaseStringUTFChars(overlayable_name, overlayable_name_native);
  if (actor == overlayable_map.end()) {
    return nullptr;
  }
+4 −5
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@

#include <jni.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedUtfChars.h>

using namespace android;
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);

    const char* captureTime = env->GetStringUTFChars(formattedCaptureTime, nullptr);

    size_t len = strlen(captureTime) + 1;
    if (len != NativeContext::DATETIME_COUNT) {
    ScopedUtfChars captureTime(env, formattedCaptureTime);
    if (captureTime.size() + 1 != NativeContext::DATETIME_COUNT) {
        jniThrowException(env, "java/lang/IllegalArgumentException",
                "Formatted capture time string length is not required 20 characters");
        return;
    }

    nativeContext->setCaptureTime(String8(captureTime));
    nativeContext->setCaptureTime(String8(captureTime.c_str()));

    DngCreator_setNativeContext(env, thiz, nativeContext);
}