diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/native/dalvik_system_Zygote.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/native/dalvik_system_Zygote.cc b/src/native/dalvik_system_Zygote.cc index 5fb435c61f..1dd6c59035 100644 --- a/src/native/dalvik_system_Zygote.cc +++ b/src/native/dalvik_system_Zygote.cc @@ -416,15 +416,25 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra #if defined(HAVE_ANDROID_OS) { - ScopedUtfChars se_info(env, java_se_info); - CHECK(se_info.c_str() != NULL); - ScopedUtfChars se_name(env, java_se_name); - CHECK(se_name.c_str() != NULL); - rc = selinux_android_setcontext(uid, is_system_server, se_info.c_str(), se_name.c_str()); + const char* se_info_c_str = NULL; + UniquePtr<ScopedUtfChars> se_info; + if (java_se_info != NULL) { + se_info.reset(new ScopedUtfChars(env, java_se_info)); + se_info_c_str = se_info->c_str(); + CHECK(se_info_c_str != NULL); + } + const char* se_name_c_str = NULL; + UniquePtr<ScopedUtfChars> se_name; + if (java_se_name != NULL) { + se_name.reset(new ScopedUtfChars(env, java_se_name)); + se_name_c_str = se_name->c_str(); + CHECK(se_name_c_str != NULL); + } + rc = selinux_android_setcontext(uid, is_system_server, se_info_c_str, se_name_c_str); if (rc == -1) { PLOG(FATAL) << "selinux_android_setcontext(" << uid << ", " << (is_system_server ? "true" : "false") << ", " - << "\"" << se_info.c_str() << "\", \"" << se_name.c_str() << "\") failed"; + << "\"" << se_info_c_str << "\", \"" << se_name_c_str << "\") failed"; } } #else |