diff --git a/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h b/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h index a7db5c20e921175ef6862009fe8d28e5409d42c2..47e5710e6596756387987e9be2e9303643cfc946 100644 --- a/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h +++ b/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h @@ -90,14 +90,17 @@ public: { if (recipient_ != nullptr) { sptr remoteObj = OHOS::HDI::hdi_objcast(allocator_); - remoteObj->RemoveDeathRecipient(recipient_); - recipient_ = nullptr; + if (remoteObj != nullptr) { + remoteObj->RemoveDeathRecipient(recipient_); + recipient_ = nullptr; + } } } bool AddDeathRecipient(const sptr& recipient) override { sptr remoteObj = OHOS::HDI::hdi_objcast(allocator_); + CHECK_NULLPOINTER_RETURN_VALUE(remoteObj, false); if (recipient_ != nullptr) { HDF_LOGE("%{public}s: the existing recipient is removed, and add the new. %{public}d", __func__, __LINE__); @@ -117,6 +120,7 @@ public: { if (recipient_ != nullptr) { sptr remoteObj = OHOS::HDI::hdi_objcast(allocator_); + CHECK_NULLPOINTER_RETURN_VALUE(remoteObj, false); remoteObj->RemoveDeathRecipient(recipient_); recipient_ = nullptr; }