From 258c5a4f9cdb2cdc08d3f6154056fa9491d25587 Mon Sep 17 00:00:00 2001 From: proExploit1 Date: Sat, 28 Mar 2026 21:24:51 +0300 Subject: [PATCH] Update brush_serialization_jni.cc Signed-off-by: proExploit1 --- .../internal/jni/brush_serialization_jni.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ink/storage/internal/jni/brush_serialization_jni.cc b/ink/storage/internal/jni/brush_serialization_jni.cc index 1c838387..c4bd62a2 100644 --- a/ink/storage/internal/jni/brush_serialization_jni.cc +++ b/ink/storage/internal/jni/brush_serialization_jni.cc @@ -216,13 +216,26 @@ JNI_METHOD(storage, BrushSerializationNative, jlong, env->DeleteLocalRef(encoded_id_jstring); env->DeleteLocalRef(pixel_data_jarray); - if (env->ExceptionCheck()) { +if (env->ExceptionCheck()) { // Note that we're not clearing the exception here since we want to // raise it as-is later. We're counting on the parsing code bailing out // on the first error status encountered. return absl::InternalError("onDecodeTexture raised exception."); } - std::string new_id(env->GetStringUTFChars(new_id_jstring, nullptr)); + + if (new_id_jstring == nullptr) { + return absl::InternalError("onDecodeTexture returned null."); + } + + const char* raw_new_id = env->GetStringUTFChars(new_id_jstring, nullptr); + if (raw_new_id == nullptr) { + env->DeleteLocalRef(new_id_jstring); + return absl::InternalError("GetStringUTFChars failed."); + } + + std::string new_id(raw_new_id); + env->ReleaseStringUTFChars(new_id_jstring, raw_new_id); + env->DeleteLocalRef(new_id_jstring); return new_id; };