Commit 4f1a2be3 authored by Larry Sachs's avatar Larry Sachs

[IOT-2957] Fix for crash on some Android phones.

Some Android phones (LG, HTC) crashed on removing listeners when
compiled WITH_CLOUD=1.  By reversing the order in which the
listeners were removed, the crash does not occur.

Bug: https://jira.iotivity.org/browse/IOT-2957

Change-Id: I32facaaf9a93ad6d0c7125e791c11618aa527587
Signed-off-by: Larry Sachs's avatarLarry Sachs <larry.j.sachs@intel.com>
parent c6916eea
......@@ -163,14 +163,14 @@ void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnDeleteListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
}
#endif
env->Throw((jthrowable)ex);
}
......@@ -179,14 +179,14 @@ void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnDeleteListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnDeleteListener(env, m_jwListener);
}
#endif
}
}
......@@ -189,14 +189,14 @@ void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnGetListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnGetListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnGetListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnGetListener(env, m_jwListener);
}
#endif
env->Throw((jthrowable)ex);
}
......@@ -205,14 +205,14 @@ void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnGetListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnGetListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnGetListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnGetListener(env, m_jwListener);
}
#endif
}
}
......@@ -171,14 +171,14 @@ void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
#ifndef WITH_CLOUD
m_ownerResource->removeOnObserveListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnObserveListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
#endif
env->Throw((jthrowable)ex);
}
......@@ -218,14 +218,14 @@ void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnObserveListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnObserveListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
#endif
env->Throw((jthrowable)ex);
}
......@@ -234,14 +234,14 @@ void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnObserveListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnObserveListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnObserveListener(env, m_jwListener);
}
#endif
}
}
......
......@@ -188,14 +188,14 @@ void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnPostListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnPostListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnPostListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnPostListener(env, m_jwListener);
}
#endif
env->Throw((jthrowable)ex);
}
......@@ -204,14 +204,14 @@ void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)
#ifndef WITH_CLOUD
m_ownerResource->removeOnPostListener(env, m_jwListener);
#else
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnPostListener(env, m_jwListener);
}
if (nullptr != m_ownerAccountManager)
{
m_ownerAccountManager->removeOnPostListener(env, m_jwListener);
}
if (nullptr != m_ownerResource)
{
m_ownerResource->removeOnPostListener(env, m_jwListener);
}
#endif
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment