Fix defects detected by static analysis
authorjaehyun Cho <jaehyun3.cho@samsung.com>
Wed, 1 Feb 2017 11:07:35 +0000 (20:07 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Fri, 3 Feb 2017 00:11:42 +0000 (00:11 +0000)
Change-Id: I43d5400da6e7fd2ee6265c04c36ba59e6ab05478
Signed-off-by: jaehyun Cho <jaehyun3.cho@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16953
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
java/jni/JniOcPlatform.cpp

index 5784c5f..83e4c7d 100644 (file)
@@ -1523,7 +1523,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0(
             jstring jStr = (jstring)env->GetObjectArrayElement(jDeviceTypes, i);
             if (!jStr)
             {
-                delete deviceInfo.deviceName;
+                delete[] deviceInfo.deviceName;
                 ThrowOcException(OC_STACK_INVALID_PARAM, "device type cannot be null");
                 return;
             }
@@ -1531,7 +1531,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0(
             OCResourcePayloadAddStringLL(&deviceInfo.types, env->GetStringUTFChars(jStr, nullptr));
             if (env->ExceptionCheck())
             {
-                delete deviceInfo.deviceName;
+                delete[] deviceInfo.deviceName;
                 return;
             }
 
@@ -1548,7 +1548,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0(
     {
         OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo);
 
-        delete deviceInfo.deviceName;
+        delete[] deviceInfo.deviceName;
 
         if (OC_STACK_OK != result)
         {
@@ -1668,17 +1668,17 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0(
         {
             OCStackResult result = OCPlatform::registerPlatformInfo(platformInfo);
 
-            delete platformInfo.platformID;
-            delete platformInfo.manufacturerName;
-            delete platformInfo.manufacturerUrl;
-            delete platformInfo.modelNumber;
-            delete platformInfo.dateOfManufacture;
-            delete platformInfo.platformVersion;
-            delete platformInfo.operatingSystemVersion;
-            delete platformInfo.hardwareVersion;
-            delete platformInfo.firmwareVersion;
-            delete platformInfo.supportUrl;
-            delete platformInfo.systemTime;
+            delete[] platformInfo.platformID;
+            delete[] platformInfo.manufacturerName;
+            delete[] platformInfo.manufacturerUrl;
+            delete[] platformInfo.modelNumber;
+            delete[] platformInfo.dateOfManufacture;
+            delete[] platformInfo.platformVersion;
+            delete[] platformInfo.operatingSystemVersion;
+            delete[] platformInfo.hardwareVersion;
+            delete[] platformInfo.firmwareVersion;
+            delete[] platformInfo.supportUrl;
+            delete[] platformInfo.systemTime;
 
             if (OC_STACK_OK != result)
             {