Skip to content

Commit

Permalink
Fix several jobject value check in jni controller code (#25088)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google authored and pull[bot] committed Mar 27, 2023
1 parent 0b044e2 commit 28d55fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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<jstring>(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;
Expand Down

0 comments on commit 28d55fd

Please sign in to comment.