From b2f751ae99240c7342e636116f2e6d54d8eeee19 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 12 Nov 2020 14:22:21 -0600 Subject: [PATCH] aux/android: More null checks --- .../auxiliary/android/android_load_class.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/xrt/auxiliary/android/android_load_class.cpp b/src/xrt/auxiliary/android/android_load_class.cpp index 282411711..b3efff23b 100644 --- a/src/xrt/auxiliary/android/android_load_class.cpp +++ b/src/xrt/auxiliary/android/android_load_class.cpp @@ -25,11 +25,30 @@ getAppInfo(std::string const &packageName, jobject application_context) { try { auto context = Context{application_context}; + if (context.isNull()) { + U_LOG_E("getAppInfo: application_context was null"); + return {}; + } auto packageManager = PackageManager{context.getPackageManager()}; + if (packageManager.isNull()) { + U_LOG_E( + "getAppInfo: " + "application_context.getPackageManager() returned " + "null"); + return {}; + } auto packageInfo = packageManager.getPackageInfo( packageName, PackageManager::GET_META_DATA | PackageManager::GET_SHARED_LIBRARY_FILES); + + if (packageInfo.isNull()) { + U_LOG_E( + "getAppInfo: " + "application_context.getPackageManager()." + "getPackaegInfo() returned null"); + return {}; + } return packageInfo.getApplicationInfo(); } catch (std::exception const &e) { U_LOG_E("Could get App Info: %s", e.what());