diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index d0c491e2a918ec..710da43628435e 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -1378,7 +1378,11 @@ JNI_METHOD(void, subscribe) params.mIsFabricFiltered = (isFabricFiltered != JNI_FALSE); params.mTimeout = imTimeoutMs != 0 ? System::Clock::Milliseconds32(imTimeoutMs) : System::Clock::kZero; - SuccessOrExit(err = JniReferences::GetInstance().GetListSize(attributePathList, numAttributePaths)); + if (attributePathList != nullptr) + { + SuccessOrExit(err = JniReferences::GetInstance().GetListSize(attributePathList, numAttributePaths)); + } + if (numAttributePaths > 0) { std::unique_ptr attributePaths(new chip::app::AttributePathParams[numAttributePaths]); @@ -1398,7 +1402,11 @@ JNI_METHOD(void, subscribe) attributePaths.release(); } - SuccessOrExit(err = JniReferences::GetInstance().GetListSize(eventPathList, numEventPaths)); + if (eventPathList != nullptr) + { + SuccessOrExit(err = JniReferences::GetInstance().GetListSize(eventPathList, numEventPaths)); + } + if (numEventPaths > 0) { std::unique_ptr eventPaths(new chip::app::EventPathParams[numEventPaths]);