Skip to content

Commit

Permalink
[android] Fix crash if decode .heic image in 32bit mode android app. (f…
Browse files Browse the repository at this point in the history
…lutter#36859)

* [android] Fix crash if decode .heic image in 32bit mode android app.

The type |long| is equal to int32_t in 32bit app, but int64_t in 64bit app.
The type |jlong| is always equal to int64_t.
CallStaticObjectMethod uses "J" to request a jlong type which needs 8 byte data but given |long| value which provides 4 byte data in 32bit mode will trigger java value error and at last a wrong pointer to AndroidImageGenerator object.

Change-Id: I38cc46adc45d8bf3e4eb35e6e904e58ee0682d97

* fix compile error

Change-Id: I7f9b089f7846b03c4b6f91f8cb9d141403e71483

* use reinterpret_cast<jlong> directly.

Change-Id: I493a3ecb7cfbf9dc61cd8e69f418635480d4bb6b
  • Loading branch information
toneyzeng authored Oct 24, 2022
1 parent 106b6f4 commit 2c9cd31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion shell/platform/android/android_image_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void AndroidImageGenerator::DoDecodeImage() {
auto bitmap = std::make_unique<fml::jni::ScopedJavaGlobalRef<jobject>>(
env, env->CallStaticObjectMethod(g_flutter_jni_class->obj(),
g_decode_image_method, direct_buffer,
reinterpret_cast<long>(this)));
reinterpret_cast<jlong>(this)));
FML_CHECK(fml::jni::CheckException(env));

if (bitmap->is_null()) {
Expand Down

0 comments on commit 2c9cd31

Please sign in to comment.