Skip to content

Fix GetPlatformAppByName() crash on KitKat when the app was not found #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/src/app_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,13 @@ static jobject GetPlatformAppByName(JNIEnv* jni_env, const char* name) {
name_string);
jni_env->DeleteLocalRef(name_string);
}
jni_env->ExceptionCheck();
if (jni_env->ExceptionCheck()) {
// Explicitly set `platform_app` to `NULL` if an exception was thrown
// because on KitKat (API 19) `CallStaticObjectMethod()` may return garbage
// instead of `NULL` if an exception was thrown, and callers of this
// function expect `NULL` to be returned if the app was not found.
platform_app = NULL; // NOLINT
}
jni_env->ExceptionClear();
return platform_app;
}
Expand Down
5 changes: 4 additions & 1 deletion release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ code.
API.
- Remote Config(Android): Fix for getting Remote Config instance for a
specific app object.
([#991](https://github.com/firebase/quickstart-unity/issues/991).
([#991](https://github.com/firebase/quickstart-unity/issues/991)).
- General (Android): Fixed a potential SIGABRT when an app was created
with a non-default app name on Android KitKat
([#429](https://github.com/firebase/firebase-cpp-sdk/pull/429)).

### 7.3.0
- Changes
Expand Down