Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / android / android_api / base / jni / JniOcSecureResource.cpp
index f06b9bb..77c8dc6 100644 (file)
@@ -211,12 +211,14 @@ OCStackResult JniOcSecureResource::provisionACL(JNIEnv* env, jobject _acl, jobje
     OCStackResult ret;
     JniProvisionResultListner *resultListener = AddProvisionResultListener(env, jListener);
     OicSecAcl_t *acl = new OicSecAcl_t;
-    acl->next = nullptr;
+
     if (!acl)
     {
         return OC_STACK_NO_MEMORY;
     }
 
+    acl->next = nullptr;
+
     if (OC_STACK_OK != JniSecureUtils::convertJavaACLToOCAcl(env, _acl, acl))
     {
         delete acl;
@@ -354,6 +356,12 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_removeDevice
 (JNIEnv *env, jobject thiz, jint timeout, jobject jListener)
 {
     LOGD("OcSecureResource_removeDevice");
+    if (timeout < 0)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Timeout value cannot be negative");
+        return;
+    }
+
     if (!jListener)
     {
         ThrowOcException(OC_STACK_INVALID_PARAM, "provisionResultListener cannot be null");
@@ -564,6 +572,7 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcSecureResource_getLinkedDevic
     {
         LOGE("%s", e.reason().c_str());
         ThrowOcException(e.code(), e.reason().c_str());
+        return nullptr;
     }
 }