Skip to content

Commit

Permalink
Fix crash when handling jStayActiveMsec (#35997)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google authored Oct 10, 2024
1 parent a7bbd7b commit 88bf438
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,15 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyICDRegistrationInfo(chip::Contro
"()Ljava/lang/Long;", &getICDStayActiveDurationMsecMethod);
ReturnErrorOnFailure(err);
jobject jStayActiveMsec = env->CallObjectMethod(icdRegistrationInfo, getICDStayActiveDurationMsecMethod);
if (jStayActiveMsec != 0)
if (jStayActiveMsec != nullptr)
{
params.SetICDStayActiveDurationMsec(chip::JniReferences::GetInstance().IntegerToPrimitive(jStayActiveMsec));
jlong stayActiveMsec = chip::JniReferences::GetInstance().LongToPrimitive(jStayActiveMsec);
if (!chip::CanCastTo<uint32_t>(stayActiveMsec))
{
ChipLogError(Controller, "Failed to process stayActiveMsec in %s since this is not a valid 32-bit integer.", __func__);
return CHIP_ERROR_INVALID_ARGUMENT;
}
params.SetICDStayActiveDurationMsec(static_cast<uint32_t>(stayActiveMsec));
}

jmethodID getCheckInNodeIdMethod;
Expand Down

0 comments on commit 88bf438

Please sign in to comment.