[IOT-1040] Fixed for jira issue about RH android. 87/7687/3
authorjyong2.kim <jyong2.kim@samsung.com>
Thu, 24 Mar 2016 23:02:57 +0000 (08:02 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 11 Apr 2016 11:07:55 +0000 (11:07 +0000)
prevented crash when init is called with null String at address.

Change-Id: I390fdd036e6afae44af36d935564b2fa5045d990
Signed-off-by: jyong2.kim <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6307
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Hun-je Yeon <hunje.yeon@samsung.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit 9cbaf9309f0f671b899641a3ed2286621b5b6ed5)
Reviewed-on: https://gerrit.iotivity.org/gerrit/7687

service/resource-hosting/android/resource_hosting/jni/ResourceHosing_JNI.cpp

index faca8ce..dde9d72 100644 (file)
@@ -91,17 +91,16 @@ JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoor
 JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingInit
 (JNIEnv *env, jobject obj,jstring j_addr)
 {
-    const char* addr = env->GetStringUTFChars(j_addr,NULL);
-
     if (NULL == j_addr)
+    {
         return (jint)OCSTACK_ERROR;
+    }
 
-    if(OCInit(addr,USE_RANDOM_PORT,OC_CLIENT_SERVER)!=OC_STACK_OK)
+    if(OCInit1(OC_CLIENT_SERVER, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS))
     {
         return (jint)OCSTACK_ERROR;
     }
 
-    env->ReleaseStringUTFChars(j_addr,addr);
     return (jint)OCSTACK_OK;
 }