Fix crash issue when called unsubscribePresence.
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Thu, 1 Sep 2016 00:12:08 +0000 (09:12 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 1 Sep 2016 09:35:32 +0000 (09:35 +0000)
Adding null initialization code.

Change-Id: I2d52b1fa479dd1956f089d202aa01fcc7da09e52
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11069
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
android/android_api/base/jni/JniOcPlatform.cpp

index f5200aede6267771ef6e812375d6f34e65326d1d..b440bc08394b7f97898f1faf543d69022aac3026 100644 (file)
@@ -2417,17 +2417,15 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0(
             ThrowOcException(result, "unsubscribe presence has failed");
             return;
         }
-        jweak jwOnPresenceListener =
-            jniPresenceHandle->getJniOnPresenceListener()->getJWListener();
-        if (jwOnPresenceListener)
-        {
-            RemoveOnPresenceListener(env, jwOnPresenceListener);
-        }
-        jweak jwOnObserveListener =
-            jniPresenceHandle->getJniOnObserveListener()->getJWListener();
-        if (jwOnObserveListener)
+
+        JniOnPresenceListener* jniPresenceListener = jniPresenceHandle->getJniOnPresenceListener();
+        if (jniPresenceListener)
         {
-            RemoveOnObserveListener(env, jwOnObserveListener);
+            jweak jwOnPresenceListener = jniPresenceListener->getJWListener();
+            if (jwOnPresenceListener)
+            {
+                RemoveOnPresenceListener(env, jwOnPresenceListener);
+            }
         }
     }
     catch (OCException& e)