From b0248fd34774624a208a48a87f846cbbd1ecf504 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Thu, 16 Feb 2023 06:08:56 -0800 Subject: [PATCH] Fix several jobject value check in jni controller code (#25088) --- src/controller/java/CHIPDeviceController-JNI.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 78601f521f0182..1b124c5c60cf9c 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -1337,9 +1337,9 @@ CHIP_ERROR ParseAttributePath(jobject attributePath, EndpointId & outEndpointId, jobject endpointIdObj = env->CallObjectMethod(attributePath, getEndpointIdMethod); VerifyOrReturnError(endpointIdObj != nullptr, CHIP_ERROR_INCORRECT_STATE); jobject clusterIdObj = env->CallObjectMethod(attributePath, getClusterIdMethod); - VerifyOrReturnError(endpointIdObj != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(clusterIdObj != nullptr, CHIP_ERROR_INCORRECT_STATE); jobject attributeIdObj = env->CallObjectMethod(attributePath, getAttributeIdMethod); - VerifyOrReturnError(endpointIdObj != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(attributeIdObj != nullptr, CHIP_ERROR_INCORRECT_STATE); uint32_t endpointId = 0; ReturnErrorOnFailure(GetChipPathIdValue(endpointIdObj, kInvalidEndpointId, endpointId)); @@ -1455,7 +1455,7 @@ CHIP_ERROR IsWildcardChipPathId(jobject chipPathId, bool & isWildcard) ReturnErrorOnFailure(JniReferences::GetInstance().FindMethod(env, idType, "name", "()Ljava/lang/String;", &nameMethod)); jstring typeNameString = static_cast(env->CallObjectMethod(idType, nameMethod)); - VerifyOrReturnError(idType != nullptr, CHIP_JNI_ERROR_NULL_OBJECT); + VerifyOrReturnError(typeNameString != nullptr, CHIP_JNI_ERROR_NULL_OBJECT); JniUtfString typeNameJniString(env, typeNameString); isWildcard = strncmp(typeNameJniString.c_str(), "WILDCARD", 8) == 0;