summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/jni/android_os_HwBinder.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/jni/android_os_HwBinder.cpp b/core/jni/android_os_HwBinder.cpp
index 23a988a3dcc0..740b24d645a8 100644
--- a/core/jni/android_os_HwBinder.cpp
+++ b/core/jni/android_os_HwBinder.cpp
@@ -241,7 +241,14 @@ static void JHwBinder_native_registerService(
using android::hidl::manager::V1_0::IServiceManager;
sp<hardware::IBinder> binder = JHwBinder::GetNativeContext(env, thiz);
+
sp<hidl::base::V1_0::IBase> base = hidl::base::V1_0::IHwBase::asInterface(binder);
+ if (base.get() == nullptr) {
+ LOG(ERROR) << "IBinder object cannot be casted to the base interface.";
+ signalExceptionForError(env, UNKNOWN_ERROR);
+ return;
+ }
+
bool ok = hardware::defaultServiceManager()->add(
interfaceChain,
serviceName,