Skip to content

Commit

Permalink
[Android] Fix CHIPTool cluster cmds fail or app crashes (Issue projec…
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisandre Taylor committed Mar 8, 2022
1 parent 1434c51 commit 587d3b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/platform/android/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -223,7 +223,7 @@ void HandleResolve(jstring instanceName, jstring serviceType, jstring address, j
callback(reinterpret_cast<void *>(contextHandle), service, Span<Inet::IPAddress>(), 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);
Expand Down
3 changes: 2 additions & 1 deletion src/platform/android/KeyValueStoreManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(value_size, decodedLength - offset_bytes);
if (value_size + offset_bytes < decodedLength)
{
Expand Down

0 comments on commit 587d3b4

Please sign in to comment.