diff --git a/src/platform/android/DnssdImpl.cpp b/src/platform/android/DnssdImpl.cpp index 52d20525e8ca04..5dc1c3e8d9706b 100644 --- a/src/platform/android/DnssdImpl.cpp +++ b/src/platform/android/DnssdImpl.cpp @@ -44,7 +44,7 @@ jmethodID sPublishMethod = nullptr; jmethodID sRemoveServicesMethod = nullptr; } // namespace -// Implemention of functions declared in lib/dnssd/platform/Dnssd.h +// Implementation of functions declared in lib/dnssd/platform/Dnssd.h CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context) { @@ -223,7 +223,7 @@ void HandleResolve(jstring instanceName, jstring serviceType, jstring address, j callback(reinterpret_cast(contextHandle), service, Span(), error); }; - VerifyOrReturn(address != nullptr && port != 0, dispatch(CHIP_ERROR_UNKNOWN_RESOURCE_ID)); + VerifyOrReturn(!(address == nullptr || port == 0), dispatch(CHIP_ERROR_UNKNOWN_RESOURCE_ID)); JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); JniUtfString jniInstanceName(env, instanceName); diff --git a/src/platform/android/KeyValueStoreManagerImpl.cpp b/src/platform/android/KeyValueStoreManagerImpl.cpp index 46ba0354f915cb..e92d3efe3f1996 100644 --- a/src/platform/android/KeyValueStoreManagerImpl.cpp +++ b/src/platform/android/KeyValueStoreManagerImpl.cpp @@ -120,7 +120,8 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t ChipLogError(DeviceLayer, "KeyValueStoreManager base64 decoding failed"); return CHIP_ERROR_INTEGRITY_CHECK_FAILED; } - ReturnErrorCodeIf(offset_bytes >= decodedLength, CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(offset_bytes != 0 && offset_bytes >= decodedLength, + CHIP_ERROR_INVALID_ARGUMENT); size_t read_size = std::min(value_size, decodedLength - offset_bytes); if (value_size + offset_bytes < decodedLength) {